[Swift-commit] r6246 - in branches/faster/src/org/griphyn/vdl: karajan karajan/lib mapping

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri Feb 8 22:46:54 CST 2013


Author: hategan
Date: 2013-02-08 22:46:54 -0600 (Fri, 08 Feb 2013)
New Revision: 6246

Added:
   branches/faster/src/org/griphyn/vdl/mapping/ClosedArrayEntries.java
   branches/faster/src/org/griphyn/vdl/mapping/OpenArrayEntries.java
Removed:
   branches/faster/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java
   branches/faster/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java
   branches/faster/src/org/griphyn/vdl/karajan/FuturePairIterator.java
   branches/faster/src/org/griphyn/vdl/karajan/FutureWrapper.java
Modified:
   branches/faster/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
   branches/faster/src/org/griphyn/vdl/karajan/lib/Tracer.java
   branches/faster/src/org/griphyn/vdl/mapping/AbstractDataNode.java
   branches/faster/src/org/griphyn/vdl/mapping/ArrayDataNode.java
   branches/faster/src/org/griphyn/vdl/mapping/RootArrayDataNode.java
   branches/faster/src/org/griphyn/vdl/mapping/RootDataNode.java
Log:
Removed future wrappers. They were deadlock prone since updating them required locking the data node and then the wrapper, while addition of listeners to the wrapper required locking the wrapper first and then the node (to check if closed)

Deleted: branches/faster/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -1,213 +0,0 @@
-/*
- * Copyright 2012 University of Chicago
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * Created on Jun 9, 2006
- */
-package org.griphyn.vdl.karajan;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import k.rt.FutureListener;
-
-import org.globus.cog.karajan.futures.FutureEvaluationException;
-import org.globus.cog.karajan.futures.FutureIterator;
-import org.globus.cog.karajan.futures.FutureList;
-import org.globus.cog.karajan.futures.FutureNotYetAvailable;
-import org.griphyn.vdl.mapping.ArrayDataNode;
-import org.griphyn.vdl.mapping.DSHandle;
-
-public class ArrayIndexFutureList implements FutureList, FutureWrapper {    
-    private ArrayList<Object> keys;
-    private Map<?, ?> values;
-    private LinkedList<FutureListener> listeners;
-    private ArrayDataNode node;
-    private boolean purged;
-
-    public ArrayIndexFutureList(ArrayDataNode node, Map<?, ?> values) {
-        this.node = node;
-        this.values = values;
-        keys = new ArrayList<Object>();
-        keys.addAll(values.keySet());
-    }
-
-    public Object get(int index) {
-        synchronized(node) {
-            Object v = node.getValue();
-            if (v instanceof RuntimeException) {
-                throw (RuntimeException) v;
-            }
-            if (!node.isClosed() && index >= keys.size()) {
-                throw new FutureNotYetAvailable(this);
-            }
-            else {
-                Object key = keys.get(index);
-                return new Pair(key, values.get(key));
-            }
-        }
-    }
-
-    public int available() {
-        synchronized(node) {
-            return keys.size();
-        }
-    }
-
-    public void addKey(Object key) {
-        synchronized(node) {
-            keys.add(key);
-        }
-        notifyListeners();
-    }
-
-    public FutureIterator futureIterator() {
-        return new FuturePairIterator(this);
-    }
-
-    public void close() {
-        throw new UnsupportedOperationException("Not used here");
-    }
-
-    private void purge() {
-        Set<Object> allkeys = new HashSet<Object>(values.keySet());
-        allkeys.removeAll(keys);
-        // remaining keys must be added
-        keys.addAll(allkeys);
-        purged = true;
-    }
-
-    public boolean isClosed() {
-        synchronized(node) {
-            boolean closed = node.isClosed();
-            if (closed && !purged) {
-                // this is done here because no explicit close() is 
-                // ever called on this object
-                purge();
-            }
-            return closed;
-        }
-    }
-
-    public Object getValue() {
-        return this;
-    }
-    
-    public DSHandle getHandle() {
-        return node;
-    }
-
-    @Override
-    public void addListener(FutureListener l) {
-        boolean closed;
-        synchronized(this) {
-            if (listeners == null) {
-                listeners = new LinkedList<FutureListener>();
-            }
-            listeners.add(l);
-            closed = isClosed();
-        }
-        if (closed) {
-            notifyListeners();
-        }
-    }
-    
-    public void notifyListeners() {
-        List<FutureListener> ls;
-        synchronized(this) {
-            if (listeners == null) {
-                return;
-            }
-            ls = listeners;
-            listeners = null;
-        }
-        for (FutureListener l : ls) {
-            l.futureUpdated(this);
-        }
-    }
-    
-    @Override
-    public synchronized List<FutureListener> getListeners() {
-        return new LinkedList<FutureListener>(listeners);
-    }
-
-    public int size() {
-        synchronized(node) {
-            if (node.isClosed()) {
-                if (node.getValue() instanceof RuntimeException) {
-                    throw (RuntimeException) node.getValue();
-                }
-                return keys.size();
-            }
-            else {
-                throw new FutureNotYetAvailable(this);
-            }
-        }
-    }
-
-    public String toString() {
-        String l;
-        if (listeners == null) {
-            l = "no listeners";
-        }
-        else {
-            l = listeners.size() + " listeners";
-        }
-        if (!isClosed()) {
-            return "Open, " + keys.size() + " elements, " + l;
-        }
-        else {
-            if (listeners != null) {
-                System.out.println("Badness");
-            }
-            return "Closed, " + keys.size() + " elements, " + l;
-        }
-    }
-
-    public void fail(FutureEvaluationException e) {
-        synchronized(node) {
-            node.setValue(e);
-        }
-    }
-
-    public FutureEvaluationException getException() {
-        synchronized(node) {
-            Object v = node.getValue();
-            if (v instanceof FutureEvaluationException) {
-                return (FutureEvaluationException) v;
-            }
-            else {
-                return null;
-            }
-        }
-    }
-
-    public int listenerCount() {
-        synchronized(node) {
-            if (listeners == null) {
-                return 0;
-            }
-            else {
-                return listeners.size();
-            }
-        }
-    }
-}

Deleted: branches/faster/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -1,115 +0,0 @@
-/*
- * Copyright 2012 University of Chicago
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * Created on Jun 8, 2006
- */
-package org.griphyn.vdl.karajan;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import k.rt.FutureListener;
-
-import org.globus.cog.karajan.futures.FutureEvaluationException;
-import org.griphyn.vdl.mapping.AbstractDataNode;
-import org.griphyn.vdl.mapping.DSHandle;
-
-public class DSHandleFutureWrapper implements FutureWrapper {
-    private LinkedList<FutureListener> listeners;
-    private AbstractDataNode node;
-    
-    public DSHandleFutureWrapper(AbstractDataNode node) {
-        this.node = node;
-    }
-    
-    public void close() {
-        node.closeShallow();
-    }
-    
-    public boolean isClosed() {
-        return node.isClosed();
-    }
-
-    public Object getValue() {
-        Object v = node.getValue();
-        if (v instanceof RuntimeException) {
-            throw (RuntimeException) v;
-        }
-        return v;
-    }
-
-    public void fail(FutureEvaluationException e) {
-        node.setValue(e);
-    }
-    
-    @Override
-    public void addListener(FutureListener l) {
-        boolean closed;
-        synchronized(this) {
-            if (listeners == null) {
-                listeners = new LinkedList<FutureListener>();
-            }
-            WaitingThreadsMonitor.addThread(l, node);
-            listeners.add(l);
-            closed = isClosed();
-        }
-        if (closed) {
-            notifyListeners();
-        }
-    }
-    
-    public void notifyListeners() {
-        List<FutureListener> ls;
-        synchronized(this) {
-            if (listeners == null) {
-                return;
-            }
-            ls = listeners;
-            listeners = null;
-        }
-        for (FutureListener l : ls) {
-            WaitingThreadsMonitor.removeThread(l);
-            l.futureUpdated(this);
-        }
-    }
-    
-	public int listenerCount() {
-	    synchronized(node) {
-    		if (listeners == null) {
-    			return 0;
-    		}
-    		else {
-    			return listeners.size();
-    		}
-	    }
-	}
-	
-	@Override
-    public synchronized List<FutureListener> getListeners() {
-        return new LinkedList<FutureListener>(listeners);
-    }
-
-    public String toString() {
-		return "F/" + node;
-	}
-
-    @Override
-    public DSHandle getHandle() {
-        return node;
-    }
-}

Deleted: branches/faster/src/org/griphyn/vdl/karajan/FuturePairIterator.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/FuturePairIterator.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/karajan/FuturePairIterator.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -1,123 +0,0 @@
-/*
- * Copyright 2012 University of Chicago
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * Created on Jun 9, 2006
- */
-package org.griphyn.vdl.karajan;
-
-import k.rt.FutureListener;
-import k.thr.LWThread;
-
-import org.globus.cog.karajan.futures.FutureEvaluationException;
-import org.globus.cog.karajan.futures.FutureIterator;
-import org.globus.cog.karajan.futures.FutureIteratorIncomplete;
-import org.globus.cog.karajan.futures.FutureNotYetAvailable;
-
-public class FuturePairIterator implements FutureIterator {
-	private ArrayIndexFutureList array;
-	private int crt;
-
-	public FuturePairIterator(ArrayIndexFutureList array) {
-		this.array = array;
-	}
-
-	public synchronized boolean hasAvailable() {
-		return crt < array.available();
-	}
-
-	public synchronized int current() {
-		return crt;
-	}
-
-	public int count() {
-		try {
-			return array.size();
-		}
-		catch (FutureNotYetAvailable e) {
-			throw new FutureIteratorIncomplete(array, this);
-		}
-	}
-
-	public Object peek() {
-		try {
-			return array.get(crt);
-		}
-		catch (FutureNotYetAvailable e) {
-			throw new FutureIteratorIncomplete(array, this);
-		}
-	}
-
-	public void remove() {
-		throw new UnsupportedOperationException("remove");
-	}
-
-	public synchronized boolean hasNext() {
-		if (array.isClosed()) {
-			return crt < array.size();
-		}
-		else {
-			if (crt < array.available()) {
-				return true;
-			}
-			else {
-				throw new FutureIteratorIncomplete(array, this);
-			}
-		}
-	}
-
-	public synchronized Object next() {
-		if (array.isClosed()) {
-			return array.get(crt++);
-		}
-		else {
-			if (crt < array.available()) {
-				return array.get(crt++);
-			}
-			else {
-				throw new FutureIteratorIncomplete(array, this);
-			}
-		}
-	}
-
-	public void close() {
-		// nope
-	}
-
-	public boolean isClosed() {
-		return array.isClosed();
-	}
-
-	public Object getValue() {
-		return this;
-	}
-	
-	
-
-	@Override
-    public void addListener(FutureListener l) {
-		WaitingThreadsMonitor.addThread(LWThread.currentThread(), array.getHandle());
-		array.addListener(l);
-		
-    }
-	
-	private static volatile int cnt = 0;
-
-	public void fail(FutureEvaluationException e) {
-		//handled by the list
-	}
-}

Deleted: branches/faster/src/org/griphyn/vdl/karajan/FutureWrapper.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/FutureWrapper.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/karajan/FutureWrapper.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -1,35 +0,0 @@
-/*
- * Copyright 2012 University of Chicago
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.griphyn.vdl.karajan;
-
-import java.util.List;
-
-import k.rt.Future;
-import k.rt.FutureListener;
-
-import org.griphyn.vdl.mapping.DSHandle;
-
-public interface FutureWrapper extends Future {
-    int listenerCount();
-    
-    List<FutureListener> getListeners();
-    
-    void notifyListeners();
-    
-    DSHandle getHandle();
-}

Modified: branches/faster/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -67,7 +67,7 @@
 					    if (logger.isDebugEnabled()) {
                             logger.debug("Using future iterator for " + var);
                         }
-						return ((ArrayDataNode) var).getFutureList().futureIterator();
+						return ((ArrayDataNode) var).entryList();
 					}
 				}
 			}

Modified: branches/faster/src/org/griphyn/vdl/karajan/lib/Tracer.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/lib/Tracer.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/karajan/lib/Tracer.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -19,8 +19,6 @@
 import org.apache.log4j.Logger;
 import org.globus.cog.karajan.analyzer.VariableNotFoundException;
 import org.globus.cog.karajan.compiled.nodes.Node;
-import org.griphyn.vdl.engine.Karajan;
-import org.griphyn.vdl.karajan.FutureWrapper;
 import org.griphyn.vdl.mapping.AbstractDataNode;
 import org.griphyn.vdl.mapping.DSHandle;
 import org.griphyn.vdl.mapping.Mapper;
@@ -99,7 +97,7 @@
     }
 
     private String getType(Node fe) {
-        String t = Karajan.demangle(fe.getTextualName());
+        String t = fe.getTextualName();
         String nt = NAME_MAPPINGS.get(t);
         if (nt == null) {
             return t;
@@ -233,12 +231,14 @@
     }
     
     public static String getFutureName(Future future) {
-        if (future instanceof FutureWrapper) {
+        // TODO
+        /*if (future instanceof FutureWrapper) {
             return getVarName(((FutureWrapper) future).getHandle());
         }
         else {
             return future.toString();
-        }
+        }*/
+        return future.toString();
     }
     
     public static Object unwrapHandle(Object o) {

Modified: branches/faster/src/org/griphyn/vdl/mapping/AbstractDataNode.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -28,15 +28,13 @@
 import java.util.List;
 import java.util.Map;
 
-import k.rt.Future;
+import k.rt.FutureListener;
+import k.rt.FutureValue;
 import k.thr.Yield;
 
 import org.apache.log4j.Logger;
 import org.globus.cog.karajan.compiled.nodes.Node;
 import org.globus.cog.karajan.futures.FutureNotYetAvailable;
-import org.griphyn.vdl.karajan.DSHandleFutureWrapper;
-import org.griphyn.vdl.karajan.FutureTracker;
-import org.griphyn.vdl.karajan.FutureWrapper;
 import org.griphyn.vdl.karajan.Loader;
 import org.griphyn.vdl.type.Field;
 import org.griphyn.vdl.type.Type;
@@ -44,7 +42,7 @@
 
 
 
-public abstract class AbstractDataNode implements DSHandle {
+public abstract class AbstractDataNode implements DSHandle, FutureValue {
 
     static final String DATASET_URI_PREFIX = "dataset:";
 
@@ -86,8 +84,8 @@
     private String identifier;
     private Path pathFromRoot;
     
-    protected FutureWrapper wrapper;
     private int writeRefCount;
+    private List<FutureListener> listeners;
 
     protected AbstractDataNode(Field field) {
         this.field = field;
@@ -631,7 +629,8 @@
                 logger.debug("Waiting for " + this);
             }
             
-            Yield y = new FutureNotYetAvailable(getFutureWrapper());
+            System.out.println("Wait");
+            Yield y = new FutureNotYetAvailable(this);
             y.getState().addTraceElement(who);
             throw y;
         }
@@ -651,7 +650,7 @@
                 logger.debug("Waiting for " + this);
             }
             
-            throw new OOBYield(new FutureNotYetAvailable(getFutureWrapper()), this);
+            throw new OOBYield(new FutureNotYetAvailable(this), this);
         }
         else {
             if (logger.isDebugEnabled()) {
@@ -667,26 +666,31 @@
         throw new UnsupportedOperationException();
     }
     
-    public synchronized Future getFutureWrapper() {
-    	if (wrapper == null) {
-    		wrapper = new DSHandleFutureWrapper(this);
-    		FutureTracker.get().add(this, wrapper);
+    public void addListener(FutureListener l) {
+    	boolean closed;
+    	synchronized(this) {
+        	if (this.listeners == null) {
+        		this.listeners = new ArrayList<FutureListener>();
+        	}
+        	this.listeners.add(l);
+        	closed = this.closed;
     	}
-    	return wrapper;
+    	if (closed) {
+    		notifyListeners();
+    	}
     }
-    
+        
     protected void notifyListeners() {
-    	FutureWrapper wrapper;
+    	List<FutureListener> l;
     	synchronized(this) {
-    		wrapper = this.wrapper;
-    		if (closed) {
-    		    FutureTracker.get().remove(this);
-    		    this.wrapper = null;
+    		l = this.listeners;
+    		this.listeners = null;
+    	}
+    	if (l != null) {
+    		for (FutureListener ll : l) {
+    			ll.futureUpdated(this);
     		}
     	}
-    	if (wrapper != null) {
-    		wrapper.notifyListeners();
-    	}
     }
 
     public synchronized void clean() {
@@ -715,7 +719,7 @@
     @Override
     public synchronized int updateWriteRefCount(int delta) {
         this.writeRefCount += delta;
-
+       
         if (this.writeRefCount < 0) {
             throw new IllegalArgumentException("Reference count mismatch for " + this + ". Count is " + this.writeRefCount);
         }

Modified: branches/faster/src/org/griphyn/vdl/mapping/ArrayDataNode.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/mapping/ArrayDataNode.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/mapping/ArrayDataNode.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -20,18 +20,16 @@
  */
 package org.griphyn.vdl.mapping;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import k.rt.Future;
-
-import org.globus.cog.karajan.futures.FutureList;
 import org.globus.cog.karajan.futures.FutureNotYetAvailable;
-import org.griphyn.vdl.karajan.ArrayIndexFutureList;
-import org.griphyn.vdl.karajan.FutureTracker;
 import org.griphyn.vdl.type.Field;
 
 public class ArrayDataNode extends DataNode {
+	private List<Comparable<?>> keyList;
+	
 	protected ArrayDataNode(Field field, DSHandle root, DSHandle parent) {
 		super(field, root, parent);
 	}
@@ -39,7 +37,7 @@
 	public void getFringePaths(List<Path> list, Path parentPath) throws HandleOpenException {
 		checkMappingException();
 		if (!isClosed()) {
-		    throw new FutureNotYetAvailable(getFutureWrapper());
+		    throw new FutureNotYetAvailable(this);
 		}
 		Map<Comparable<?>, DSHandle> handles = getHandles();
 		synchronized (this) {
@@ -93,13 +91,12 @@
     }
     
     private void addKey(Comparable<?> key) {
-        ArrayIndexFutureList w;
-        synchronized(this) {
-            w = (ArrayIndexFutureList) wrapper;
-        }
-        if (w != null) {
-            w.addKey(key);
-        }
+    	synchronized(this) {
+    		if (keyList != null) {
+    			keyList.add(key);
+    		}
+    	}
+        notifyListeners();
     }
     
     @Override
@@ -108,20 +105,27 @@
         addKey(key);
         return h;
     }
-
-    @Override
-    public synchronized Future getFutureWrapper() {
-    	if (wrapper == null) {
-    		wrapper = new ArrayIndexFutureList(this, this.getArrayValue());
-    		FutureTracker.get().add(this, wrapper);
+    
+    public Iterable<List<?>> entryList() {
+    	synchronized(this) {
+    		if (isClosed()) {
+    			return new ClosedArrayEntries(getArrayValue());
+    		}
+    		else {
+    			keyList = new ArrayList<Comparable<?>>(getArrayValue().keySet());
+    			return new OpenArrayEntries(keyList, getArrayValue(), this);
+    		}
     	}
-        return wrapper;
     }
+    
+    @Override
+    public void closeShallow() {
+        super.closeShallow();
+        synchronized(this) {
+        	keyList = null;
+        }
+    }
 
-    public FutureList getFutureList() {
-        return (FutureList) getFutureWrapper();
-    }
-    
     protected void getFields(List<DSHandle> fields, Path path) throws InvalidPathException {
         if (path.isEmpty()) {
             fields.add(this);
@@ -130,7 +134,7 @@
             Path rest = path.butFirst();
             if (path.isWildcard(0)) {
                 if (!isClosed()) {
-                    throw new FutureNotYetAvailable(getFutureWrapper());
+                    throw new FutureNotYetAvailable(this);
                 }
                 for (DSHandle handle : getHandles().values()) {
                     ((AbstractDataNode) handle).getFields(fields, rest);

Added: branches/faster/src/org/griphyn/vdl/mapping/ClosedArrayEntries.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/mapping/ClosedArrayEntries.java	                        (rev 0)
+++ branches/faster/src/org/griphyn/vdl/mapping/ClosedArrayEntries.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -0,0 +1,47 @@
+//----------------------------------------------------------------------
+//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 Feb 5, 2013
+ */
+package org.griphyn.vdl.mapping;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.griphyn.vdl.karajan.Pair;
+
+public class ClosedArrayEntries implements Iterable<List<?>> {
+    private Map<Comparable<?>, DSHandle> array;
+
+    public ClosedArrayEntries(Map<Comparable<?>, DSHandle> array) {
+        this.array = array;
+    }
+
+    @Override
+    public Iterator<List<?>> iterator() {
+        final Iterator<Map.Entry<Comparable<?>, DSHandle>> it = array.entrySet().iterator();
+        return new Iterator<List<?>>() {
+
+            @Override
+            public boolean hasNext() {
+                return it.hasNext();
+            }
+
+            @Override
+            public List<?> next() {
+                Map.Entry<Comparable<?>, DSHandle> e = it.next();
+                return new Pair(e.getKey(), e.getValue());
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+}

Added: branches/faster/src/org/griphyn/vdl/mapping/OpenArrayEntries.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/mapping/OpenArrayEntries.java	                        (rev 0)
+++ branches/faster/src/org/griphyn/vdl/mapping/OpenArrayEntries.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -0,0 +1,78 @@
+//----------------------------------------------------------------------
+//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 Feb 5, 2013
+ */
+package org.griphyn.vdl.mapping;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import k.rt.ConditionalYield;
+
+import org.griphyn.vdl.karajan.Pair;
+
+public class OpenArrayEntries implements Iterable<List<?>> {
+    private List<Comparable<?>> keyList;
+    private Map<Comparable<?>, DSHandle> array;
+    private ArrayDataNode source;
+
+    public OpenArrayEntries(List<Comparable<?>> keyList, Map<Comparable<?>, DSHandle> array, ArrayDataNode source) {
+        this.keyList = keyList;
+        this.array = array;
+        this.source = source;
+    }
+
+    @Override
+    public Iterator<List<?>> iterator() {
+        return new Iterator<List<?>>() {
+            private int index = 0;
+
+            @Override
+            public boolean hasNext() {
+                synchronized(source) {
+                    if (index < keyList.size()) {
+                        return true;
+                    }
+                    else {
+                        if (source.isClosed()) {
+                            return false;
+                        }
+                        else {
+                            throw new ConditionalYield(source);
+                        }
+                    }
+                }
+            }
+
+            @Override
+            public List<?> next() {
+                synchronized(source) {
+                    if (index < keyList.size()) {
+                        Comparable<?> key = keyList.get(index++);
+                        return new Pair(key, array.get(key));
+                    }
+                    else {
+                        if (source.isClosed()) {
+                            throw new NoSuchElementException();
+                        }
+                        else {
+                            throw new ConditionalYield(source);
+                        }
+                    }
+                }
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+}

Modified: branches/faster/src/org/griphyn/vdl/mapping/RootArrayDataNode.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/mapping/RootArrayDataNode.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/mapping/RootArrayDataNode.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -67,7 +67,7 @@
 	    
 		waitingMapperParam = params.getFirstOpenParamValue();
         if (waitingMapperParam != null) {
-            waitingMapperParam.getFutureWrapper().addListener(this);
+            waitingMapperParam.addListener(this);
             if (tracer.isEnabled()) {
                 tracer.trace(getThread(), getDeclarationLine(), getDisplayableName() + " WAIT " 
                     + Tracer.getVarName(waitingMapperParam));
@@ -144,7 +144,7 @@
             return null;
         }
         else {
-            throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
+            throw new FutureNotYetAvailable(waitingMapperParam);
         }
 	}
 	

Modified: branches/faster/src/org/griphyn/vdl/mapping/RootDataNode.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/mapping/RootDataNode.java	2013-02-09 04:38:08 UTC (rev 6245)
+++ branches/faster/src/org/griphyn/vdl/mapping/RootDataNode.java	2013-02-09 04:46:54 UTC (rev 6246)
@@ -72,7 +72,7 @@
 	private synchronized void innerInit() throws HandleOpenException {
 	    waitingMapperParam = params.getFirstOpenParamValue();
 	    if (waitingMapperParam != null) {
-            waitingMapperParam.getFutureWrapper().addListener(this);
+            waitingMapperParam.addListener(this);
             if (tracer.isEnabled()) {
                 tracer.trace(getThread(), getDeclarationLine(), getDisplayableName() + " WAIT " 
                     + Tracer.getVarName(waitingMapperParam));
@@ -260,7 +260,7 @@
 		    return null;
 		}
 		else {        
-		    throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
+		    throw new FutureNotYetAvailable(waitingMapperParam);
 		}
 	}
 	




More information about the Swift-commit mailing list