[Swift-commit] r7777 - in branches/release-0.94/src/org/griphyn/vdl: karajan mapping
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Thu Apr 17 20:29:19 CDT 2014
Author: hategan
Date: 2014-04-17 20:29:19 -0500 (Thu, 17 Apr 2014)
New Revision: 7777
Added:
branches/release-0.94/src/org/griphyn/vdl/mapping/FutureArrayOpen.java
Modified:
branches/release-0.94/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java
branches/release-0.94/src/org/griphyn/vdl/mapping/ArrayDataNode.java
Log:
fix for busy loop when waiting for a full array for which some elements are available
Modified: branches/release-0.94/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java
===================================================================
--- branches/release-0.94/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java 2014-04-17 20:56:54 UTC (rev 7776)
+++ branches/release-0.94/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java 2014-04-18 01:29:19 UTC (rev 7777)
@@ -121,15 +121,19 @@
public DSHandle getHandle() {
return node;
}
+
+ public void addModificationAction(FutureListener target, VariableStack stack) {
+ addModificationAction(target, stack, true);
+ }
- public void addModificationAction(FutureListener target, VariableStack stack) {
+ public void addModificationAction(FutureListener target, VariableStack stack, boolean partialUpdates) {
synchronized(node) {
if (listeners == null) {
listeners = new LinkedList<ListenerStackPair>();
}
listeners.add(new ListenerStackPair(target, stack));
WaitingThreadsMonitor.addThread(stack, node);
- if (!node.isClosed() && keys.isEmpty()) {
+ if (!node.isClosed() && (keys.isEmpty() || !partialUpdates)) {
return;
}
}
Modified: branches/release-0.94/src/org/griphyn/vdl/mapping/ArrayDataNode.java
===================================================================
--- branches/release-0.94/src/org/griphyn/vdl/mapping/ArrayDataNode.java 2014-04-17 20:56:54 UTC (rev 7776)
+++ branches/release-0.94/src/org/griphyn/vdl/mapping/ArrayDataNode.java 2014-04-18 01:29:19 UTC (rev 7777)
@@ -38,7 +38,7 @@
public void getFringePaths(List<Path> list, Path parentPath) throws HandleOpenException {
checkMappingException();
if (!isClosed()) {
- throw new FutureNotYetAvailable(getFutureWrapper());
+ throw new FutureArrayOpen((ArrayIndexFutureList) getFutureWrapper());
}
Map<Comparable<?>, DSHandle> handles = getHandles();
synchronized (this) {
@@ -55,7 +55,7 @@
}
}
- /** Recursively closes arrays through a tree of arrays and complex
+ /** Recursively closes arrays through a tree of arrays and complex
types. */
public void closeDeep() {
assert(this.getType().isArray());
@@ -121,6 +121,22 @@
return (FutureList) getFutureWrapper();
}
+ @Override
+ public synchronized void waitFor() {
+ if (!isClosed()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Waiting for " + this);
+ }
+ throw new FutureArrayOpen((ArrayIndexFutureList) getFutureWrapper());
+ }
+ else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Do not need to wait for " + this);
+ }
+ checkDataException();
+ }
+ }
+
protected void getFields(List<DSHandle> fields, Path path) throws InvalidPathException {
if (path.isEmpty()) {
fields.add(this);
Added: branches/release-0.94/src/org/griphyn/vdl/mapping/FutureArrayOpen.java
===================================================================
--- branches/release-0.94/src/org/griphyn/vdl/mapping/FutureArrayOpen.java (rev 0)
+++ branches/release-0.94/src/org/griphyn/vdl/mapping/FutureArrayOpen.java 2014-04-18 01:29:19 UTC (rev 7777)
@@ -0,0 +1,61 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Apr 17, 2014
+ */
+package org.griphyn.vdl.mapping;
+
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.workflow.futures.Future;
+import org.globus.cog.karajan.workflow.futures.FutureEvaluationException;
+import org.globus.cog.karajan.workflow.futures.FutureListener;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+import org.griphyn.vdl.karajan.ArrayIndexFutureList;
+
+public class FutureArrayOpen extends FutureNotYetAvailable {
+ public FutureArrayOpen(ArrayIndexFutureList f) {
+ super(new Wrapper(f));
+ }
+
+ @Override
+ public Future getFuture() {
+ return super.getFuture();
+ }
+
+ private static class Wrapper implements Future {
+ private final ArrayIndexFutureList f;
+
+ public Wrapper(ArrayIndexFutureList f) {
+ this.f = f;
+ }
+
+ @Override
+ public void close() {
+ f.close();
+ }
+
+ @Override
+ public boolean isClosed() {
+ return f.isClosed();
+ }
+
+ @Override
+ public Object getValue() {
+ return f.getValue();
+ }
+
+ @Override
+ public void fail(FutureEvaluationException e) {
+ f.fail(e);
+ }
+
+ @Override
+ public void addModificationAction(FutureListener target, VariableStack stack) {
+ f.addModificationAction(target, stack, false);
+ }
+ }
+}
More information about the Swift-commit
mailing list