[Swift-commit] r2391 - trunk/src/org/griphyn/vdl/karajan/lib

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Jan 5 07:45:59 CST 2009


Author: benc
Date: 2009-01-05 07:45:58 -0600 (Mon, 05 Jan 2009)
New Revision: 2391

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
Log:
change locking on closes to be on the root of a datanode, rather than on the data node itself

Modified: trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2009-01-05 10:29:53 UTC (rev 2390)
+++ trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2009-01-05 13:45:58 UTC (rev 2391)
@@ -405,7 +405,7 @@
 		WrapperMap hash = getFutureWrapperMap(stack);
 		// Close the future
 		boolean closed;
-		synchronized(handle) {
+		synchronized(handle.getRoot()) {
 			closed = handle.isClosed();
 			if (!closed) {
 				handle.closeShallow();
@@ -434,28 +434,33 @@
 		// Also mark all arrays from root
 		Path fullPath = handle.getPathFromRoot();
 		DSHandle root = handle.getRoot();
-		for (int i = 0; i < fullPath.size(); i++) {
-			if (fullPath.isArrayIndex(i)) {
-				try {
-					markAsAvailable(stack, root.getField(fullPath.subPath(0, i)),
-							fullPath.getElement(i));
+		synchronized(root) {
+			for (int i = 0; i < fullPath.size(); i++) {
+				if (fullPath.isArrayIndex(i)) {
+					try {
+						markAsAvailable(stack, root.getField(fullPath.subPath(0, i)),
+								fullPath.getElement(i));
+					}
+					catch (InvalidPathException e) {
+						e.printStackTrace();
+					}
 				}
-				catch (InvalidPathException e) {
-					e.printStackTrace();
-				}
 			}
 		}
 	}
 
 	protected void waitFor(VariableStack stack, DSHandle handle) throws ExecutionException {
-		if (!handle.isClosed()) {
-			throw new FutureNotYetAvailable(addFutureListener(stack, handle));
+		synchronized(handle.getRoot()) {
+			if (!handle.isClosed()) {
+				throw new FutureNotYetAvailable(addFutureListener(stack, handle));
+			}
 		}
 	}
 
 	private void closeDeep(VariableStack stack, DSHandle handle) throws ExecutionException,
 			InvalidPathException {
 		// Close the future
+		synchronized(handle.getRoot()) {
 		handle.closeShallow();
 		getFutureWrapperMap(stack).close(handle);
 		try {
@@ -470,14 +475,18 @@
 			throw new ExecutionException("HandleOpen during closeDeep",e);
 		}
 		markToRoot(stack, handle);
+		}
 	}
 
 	protected void closeShallow(VariableStack stack, DSHandle handle) throws ExecutionException {
-		handle.closeShallow();
-		getFutureWrapperMap(stack).close(handle);
+		synchronized(handle.getRoot()) {
+			handle.closeShallow();
+			getFutureWrapperMap(stack).close(handle);
+		}
 	}
 
 	private boolean isClosed(VariableStack stack, DSHandle handle) throws ExecutionException {
+		assert Thread.holdsLock(handle.getRoot());
 		return getFutureWrapperMap(stack).isClosed(handle);
 	}
 




More information about the Swift-commit mailing list