[Swift-commit] r2371 - in trunk/src/org/griphyn/vdl/karajan/lib: . swiftscript

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Sun Dec 14 14:04:53 CST 2008


Author: benc
Date: 2008-12-14 14:04:53 -0600 (Sun, 14 Dec 2008)
New Revision: 2371

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
Log:
synchronization around filename calls - this is needed later on when there is more parallelism

Modified: trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2008-12-14 18:32:32 UTC (rev 2370)
+++ trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2008-12-14 20:04:53 UTC (rev 2371)
@@ -175,14 +175,17 @@
 
 	public String[] filename(VariableStack stack) throws ExecutionException {
 		DSHandle ovar = (DSHandle)PA_VAR.getValue(stack);
-		try {
-			return filename(ovar);
+		synchronized(ovar.getRoot()) {
+			try {
+				return filename(ovar);
+			}
+			catch (HandleOpenException e) {
+				throw new FutureNotYetAvailable(addFutureListener(stack, e.getSource()));
+			}
 		}
-		catch (HandleOpenException e) {
-			throw new FutureNotYetAvailable(addFutureListener(stack, e.getSource()));
-		}
 	} 
 
+	/** The caller is expected to have synchronized on the root of var. */
 	public String[] filename(DSHandle var) throws ExecutionException, HandleOpenException {
 		try {
 			if (var.getType().isArray()) {

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java	2008-12-14 18:32:32 UTC (rev 2370)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java	2008-12-14 20:04:53 UTC (rev 2371)
@@ -23,13 +23,15 @@
 		DSHandle handle = null;
 		try {
 			handle = (DSHandle) PA_VAR.getValue(stack);
-			String fn = argList(filename(handle), true);
-			Reader freader = new FileReader(fn);
-			BufferedReader breader = new BufferedReader(freader);
-			String str = breader.readLine();
-			freader.close();
-			Double i = new Double(str);
-			return RootDataNode.newNode(Types.FLOAT, i);
+			synchronized(handle.getRoot()) {
+				String fn = argList(filename(handle), true);
+				Reader freader = new FileReader(fn);
+				BufferedReader breader = new BufferedReader(freader);
+				String str = breader.readLine();
+				freader.close();
+				Double i = new Double(str);
+				return RootDataNode.newNode(Types.FLOAT, i);
+			}
 		}
 		catch (IOException ioe) {
 			throw new ExecutionException("Reading integer content of file", ioe);




More information about the Swift-commit mailing list