[Swift-commit] r5833 - trunk/src/org/griphyn/vdl/mapping

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Sat Jul 14 19:00:00 CDT 2012


Author: hategan
Date: 2012-07-14 19:00:00 -0500 (Sat, 14 Jul 2012)
New Revision: 5833

Modified:
   trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
   trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java
Log:
removed synchronization on handles. All sync is done on the handle.

Modified: trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2012-07-14 06:33:58 UTC (rev 5832)
+++ trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2012-07-15 00:00:00 UTC (rev 5833)
@@ -29,7 +29,6 @@
 
 import org.apache.log4j.Logger;
 import org.globus.cog.karajan.workflow.futures.Future;
-import org.globus.cog.karajan.workflow.futures.FutureFault;
 import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
 import org.griphyn.vdl.karajan.DSHandleFutureWrapper;
 import org.griphyn.vdl.karajan.FutureTracker;
@@ -266,30 +265,24 @@
         ((AbstractDataNode) getParent()).setField(field.getId(), handle);
     }
 
-    protected void setField(Comparable<?> id, DSHandle handle) {
-        synchronized (handles) {
-            handles.put(id, handle);
-        }
+    protected synchronized void setField(Comparable<?> id, DSHandle handle) {
+        handles.put(id, handle);
     }
 
-    protected DSHandle getField(Comparable<?> key)
+    protected synchronized DSHandle getField(Comparable<?> key)
         throws NoSuchFieldException {
-        synchronized(handles) {
-            DSHandle handle = handles.get(key);
-            if (handle == null) {
-                if (closed) {
-                    throw new NoSuchFieldException(key.toString());
-                }
-                handle = createField(key);
+        DSHandle handle = handles.get(key);
+        if (handle == null) {
+            if (closed) {
+                throw new NoSuchFieldException(key.toString());
             }
-            return handle;
+            handle = createField(key);
         }
+        return handle;
     }
 
-    protected boolean isHandlesEmpty() {
-        synchronized (handles) {
-            return handles.isEmpty();
-        }
+    protected synchronized boolean isHandlesEmpty() {
+        return handles.isEmpty();
     }
 
     public DSHandle createField(Comparable<?> key)
@@ -302,14 +295,12 @@
         return addHandle(key, newNode(getChildField(key)));
     }
     
-    protected DSHandle addHandle(Comparable<?> id, DSHandle handle) {
-        synchronized (handles) {
-            Object o = handles.put(id, handle);
-            if (o != null) {
-                throw new RuntimeException(
-                    "Trying to create a handle that already exists ("
-                    + id + ") in " + this);
-            }
+    protected synchronized DSHandle addHandle(Comparable<?> id, DSHandle handle) {
+        Object o = handles.put(id, handle);
+        if (o != null) {
+            throw new RuntimeException(
+                "Trying to create a handle that already exists ("
+                + id + ") in " + this);
         }
         return handle;
     }
@@ -516,7 +507,7 @@
             }
         }
 
-        synchronized (handles) {
+        synchronized (this) {
             //Iterator i = handles.entrySet().iterator();
             //while (i.hasNext()) {
             //    Map.Entry e = (Map.Entry) i.next();
@@ -543,11 +534,9 @@
         if (!this.closed) {
             closeShallow();
         }
-        synchronized (handles) {
-            for (DSHandle handle : handles.values()) {
-                AbstractDataNode mapper = (AbstractDataNode) handle;
-                mapper.closeDeep();
-            }
+        for (DSHandle handle : handles.values()) {
+            AbstractDataNode mapper = (AbstractDataNode) handle;
+            mapper.closeDeep();
         }
     }
 	
@@ -558,7 +547,7 @@
         if (!this.closed && this.getType().isArray()) {
             closeShallow();
         }
-        synchronized (handles) {
+        synchronized (this) {
             for (DSHandle handle : handles.values()) {
                 AbstractDataNode child = (AbstractDataNode) handle;
                 if (child.getType().isArray() ||
@@ -623,7 +612,7 @@
         throw new UnsupportedOperationException();
     }
     
-    protected synchronized Future getFutureWrapper() {
+    public synchronized Future getFutureWrapper() {
     	if (wrapper == null) {
     		wrapper = new DSHandleFutureWrapper(this);
     		FutureTracker.get().add(this, wrapper);

Modified: trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java	2012-07-14 06:33:58 UTC (rev 5832)
+++ trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java	2012-07-15 00:00:00 UTC (rev 5833)
@@ -41,7 +41,7 @@
 		    throw new FutureNotYetAvailable(getFutureWrapper());
 		}
 		Map<Comparable<?>, DSHandle> handles = getHandles();
-		synchronized (handles) {
+		synchronized (this) {
 			for (Map.Entry<Comparable<?>, DSHandle> e : handles.entrySet()) {
 				AbstractDataNode mapper = (AbstractDataNode) e.getValue();
 				Path fullPath = parentPath.addLast(e.getKey(), getType().isArray());
@@ -61,7 +61,7 @@
         assert(this.getType().isArray());
         closeShallow();
         Map<Comparable<?>, DSHandle> handles = getHandles();
-        synchronized (handles) {
+        synchronized (this) {
         	for (Map.Entry<Comparable<?>, DSHandle> e : handles.entrySet()) {
                 AbstractDataNode child = (AbstractDataNode) e.getValue();
                 child.closeDeep();
@@ -79,7 +79,7 @@
 	
     @Override
     protected void setField(Comparable<?> id, DSHandle handle) {
-        synchronized(getHandles()) {
+        synchronized(this) {
             super.setField(id, handle);
             // Operations on the handles and the wrapper keys need to be synchronized.
             // When a wrapper is created, it populates its list of keys with the handles
@@ -98,23 +98,19 @@
     }
     
     @Override
-    public DSHandle createField(Comparable<?> key) throws NoSuchFieldException {
-        synchronized(getHandles()) {
-            DSHandle h = super.createField(key);
-            addKey(key);
-            return h;
-        }
+    public synchronized DSHandle createField(Comparable<?> key) throws NoSuchFieldException {
+        DSHandle h = super.createField(key);
+        addKey(key);
+        return h;
     }
 
     @Override
-    protected Future getFutureWrapper() {
-        synchronized(getHandles()) {
-        	if (wrapper == null) {
-        		wrapper = new ArrayIndexFutureList(this, this.getArrayValue());
-        		FutureTracker.get().add(this, wrapper);
-        	}
-            return wrapper;
-        }
+    public synchronized Future getFutureWrapper() {
+    	if (wrapper == null) {
+    		wrapper = new ArrayIndexFutureList(this, this.getArrayValue());
+    		FutureTracker.get().add(this, wrapper);
+    	}
+        return wrapper;
     }
 
     public FutureList getFutureList() {




More information about the Swift-commit mailing list