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

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Jul 28 14:36:27 CDT 2010


Author: hategan
Date: 2010-07-28 14:36:27 -0500 (Wed, 28 Jul 2010)
New Revision: 3485

Modified:
   trunk/src/org/griphyn/vdl/karajan/FuturePairIterator.java
Log:
no need to chain iterator future notifications in this case since they can be added directly to the array

Modified: trunk/src/org/griphyn/vdl/karajan/FuturePairIterator.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/FuturePairIterator.java	2010-07-28 19:35:27 UTC (rev 3484)
+++ trunk/src/org/griphyn/vdl/karajan/FuturePairIterator.java	2010-07-28 19:36:27 UTC (rev 3485)
@@ -3,37 +3,25 @@
  */
 package org.griphyn.vdl.karajan;
 
-import java.util.Iterator;
-import java.util.LinkedList;
-
 import org.globus.cog.karajan.stack.VariableNotFoundException;
 import org.globus.cog.karajan.stack.VariableStack;
-import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.events.ControlEvent;
-import org.globus.cog.karajan.workflow.events.ControlEventType;
 import org.globus.cog.karajan.workflow.events.Event;
-import org.globus.cog.karajan.workflow.events.EventBus;
 import org.globus.cog.karajan.workflow.events.EventListener;
-import org.globus.cog.karajan.workflow.events.EventTargetPair;
-import org.globus.cog.karajan.workflow.futures.Future;
 import org.globus.cog.karajan.workflow.futures.FutureEvaluationException;
 import org.globus.cog.karajan.workflow.futures.FutureIterator;
 import org.globus.cog.karajan.workflow.futures.FutureIteratorIncomplete;
 import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
 
-public class FuturePairIterator implements FutureIterator, EventListener, Mergeable {
+public class FuturePairIterator implements FutureIterator {
 	private ArrayIndexFutureList array;
 	private int crt;
-	private LinkedList listeners;
 
 	public FuturePairIterator(ArrayIndexFutureList array) {
 		this.array = array;
-		array.addModificationAction(this, null);
 	}
 
 	public FuturePairIterator(ArrayIndexFutureList array, VariableStack stack) {
 		this.array = array;
-		array.addModificationAction(this, new ControlEvent(null, ControlEventType.RESTART, stack));
 	}
 
 	public synchronized boolean hasAvailable() {
@@ -107,44 +95,12 @@
 	}
 
 	public synchronized void addModificationAction(EventListener target, Event event) {
-		if (listeners == null) {
-			listeners = new LinkedList();
-		}
 		WaitingThreadsMonitor.addThread(event.getStack());
-		listeners.add(new EventTargetPair(event, target));
+		array.addModificationAction(target, event);
 	}
+	
+	private static volatile int cnt = 0;
 
-	private void notifyListeners() {
-		synchronized (this) {
-			if (listeners == null) {
-				return;
-			}
-
-			Iterator i = listeners.iterator();
-			while (i.hasNext()) {
-				EventTargetPair etp = (EventTargetPair) i.next();
-				WaitingThreadsMonitor.removeThread(etp.getEvent().getStack());
-				EventBus.post(etp.getTarget(), etp.getEvent());
-				i.remove();
-			}
-			
-			listeners = null;
-		}
-	}
-
-	public void event(Event e) throws ExecutionException {
-		notifyListeners();
-	}
-
-	public void mergeListeners(Future f) {
-		Iterator i = listeners.iterator();
-		while (i.hasNext()) {
-			EventTargetPair etp = (EventTargetPair) i.next();
-			f.addModificationAction(etp.getTarget(), etp.getEvent());
-			i.remove();
-		}
-	}
-
 	public void fail(FutureEvaluationException e) {
 		//handled by the list
 	}




More information about the Swift-commit mailing list