ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant Project.java
Date Thu, 06 Jun 2002 06:03:27 GMT
stevel      2002/06/05 23:03:27

  Modified:    src/main/org/apache/tools/ant Tag: ANT_15_BRANCH
                        Project.java
  Log:
  PR 8793; Need to synchronize core methods in Project.
  
  added sync attr to the various setters of Project state. We will take a fractional performance
hit on this, even when we arent in parallel mode, which is why I use the synchronized attribute
on the setProperty methods; that is ever so slightly faster than syncing on objects inside
a method.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.108.2.5 +32 -29    jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.108.2.4
  retrieving revision 1.108.2.5
  diff -u -r1.108.2.4 -r1.108.2.5
  --- Project.java	5 Jun 2002 07:14:09 -0000	1.108.2.4
  +++ Project.java	6 Jun 2002 06:03:27 -0000	1.108.2.5
  @@ -83,7 +83,7 @@
    *
    * @author duncan@x180.com
    *
  - * @version $Revision: 1.108.2.4 $
  + * @version $Revision: 1.108.2.5 $
    */
   
   public class Project {
  @@ -415,7 +415,7 @@
        * @param value The new value of the property.
        *              Must not be <code>null</code>.
        */
  -    public void setProperty(String name, String value) {
  +    public synchronized void setProperty(String name, String value) {
           // command line properties take precedence
           if (null != userProperties.get(name)) {
               log("Override ignored for user property " + name, MSG_VERBOSE);
  @@ -443,7 +443,7 @@
        *              Must not be <code>null</code>.
        * @since 1.5
        */
  -    public void setNewProperty(String name, String value) {
  +    public synchronized void setNewProperty(String name, String value) {
           if (null != properties.get(name)) {
               log("Override ignored for property " + name, MSG_VERBOSE);
               return;
  @@ -462,7 +462,7 @@
        *              Must not be <code>null</code>.
        * @see #setProperty(String,String)
        */
  -    public void setUserProperty(String name, String value) {
  +    public synchronized void setUserProperty(String name, String value) {
           log("Setting ro project property: " + name + " -> " +
               value, MSG_DEBUG);
           userProperties.put(name, value);
  @@ -892,23 +892,24 @@
        *                  Must not be <code>null</code>.
        */
       public void addDataTypeDefinition(String typeName, Class typeClass) {
  -        Class old = (Class) dataClassDefinitions.get(typeName);
  -        if (null != old) {
  -            if (old.equals(typeClass)) {
  -                log("Ignoring override for datatype " + typeName
  -                    + ", it is already defined by the same class.",
  -                    MSG_VERBOSE);
  -                return;
  -            } else {
  -                log("Trying to override old definition of datatype "
  -                    + typeName, MSG_WARN);
  +        synchronized(dataClassDefinitions) {
  +            Class old = (Class) dataClassDefinitions.get(typeName);
  +            if (null != old) {
  +                if (old.equals(typeClass)) {
  +                    log("Ignoring override for datatype " + typeName
  +                        + ", it is already defined by the same class.",
  +                        MSG_VERBOSE);
  +                    return;
  +                } else {
  +                    log("Trying to override old definition of datatype "
  +                        + typeName, MSG_WARN);
  +                }
               }
  +            dataClassDefinitions.put(typeName, typeClass);
           }
  -
           String msg = " +User datatype: " + typeName + "     "
               + typeClass.getName();
           log(msg, MSG_DEBUG);
  -        dataClassDefinitions.put(typeName, typeClass);
       }
   
       /**
  @@ -1676,22 +1677,24 @@
        * @param value The value of the reference. Must not be <code>null</code>.
        */
       public void addReference(String name, Object value) {
  -        Object old = references.get(name);
  -        if (old == value) {
  -            // no warning, this is not changing anything
  -            return;
  -        }
  -        if (old != null) {
  -            log("Overriding previous definition of reference to " + name,
  -                MSG_WARN);
  +        synchronized (references) {
  +            Object old = references.get(name);
  +            if (old == value) {
  +                // no warning, this is not changing anything
  +                return;
  +            }
  +            if (old != null) {
  +                log("Overriding previous definition of reference to " + name,
  +                    MSG_WARN);
  +            }
  +            log("Adding reference: " + name + " -> " + value, MSG_DEBUG);
  +            references.put(name, value);
           }
  -        log("Adding reference: " + name + " -> " + value, MSG_DEBUG);
  -        references.put(name, value);
       }
   
       /**
        * Returns a map of the references in the project (String to Object).
  -     * The returned hashtable is "live" and so should not be modified.
  +     * The returned hashtable is "live" and so must not be modified.
        *
        * @return a map of the references in the project (String to Object).
        */
  @@ -1925,9 +1928,9 @@
        *
        * @param thread the thread on which the task is registered.
        * @param task the task to be registered.
  -     * @since 1.102, Ant 1.5
  +     * @since Ant 1.5
        */
  -    public void registerThreadTask(Thread thread, Task task) {
  +    public synchronized void registerThreadTask(Thread thread, Task task) {
           if (task != null) {
               threadTasks.put(thread, task);
           } else {
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message