more cleanup
[fleet.git] / src / edu / berkeley / fleet / dataflow / Node.java
index 5684e84..383121e 100644 (file)
@@ -14,8 +14,9 @@ import static edu.berkeley.fleet.util.BitManipulations.*;
 
 public class Node {
 
-    void doReset(Context ctx, int phase, Dock dock, Port peer, Destination ackDestination, boolean peerUsed) {
-        if (dock.getShip().getType().equals("Debug")) return;
+    int doReset(Context ctx, int phase, Dock dock, Port peer, Destination ackDestination, boolean peerUsed) {
+        int ret = 0;
+        if (dock.getShip().getType().equals("Debug")) return ret;
 
         switch(phase) {
 
@@ -34,7 +35,7 @@ public class Node {
                     lf = lf.makeNext(0);
                     lf.abortLoopIfTorpedoPresent();
                     lf.collectWord();
-                    DataFlowGraph.reset_count++;
+                    ret++;
                 }
                 break;
             }
@@ -56,7 +57,7 @@ public class Node {
                         ((OutPort)peer).recvWord(lf);
                         ((OutPort)peer).sendToken(lf);
                     }
-                    DataFlowGraph.reset_count++;
+                    ret++;
                 }
                 break;
             }
@@ -70,7 +71,7 @@ public class Node {
                         for(int i=0; i<((InPort)peer).getTokensToAbsorb(); i++)
                             lf.recvToken();
                     lf.sendToken(ackDestination);
-                    DataFlowGraph.reset_count++;
+                    ret++;
                 }
                 break;
             }
@@ -83,13 +84,12 @@ public class Node {
                     }
                     LoopFactory lf = new LoopFactory(ctx, dock, 1);
                     lf.sendToken(ackDestination);
-                    DataFlowGraph.reset_count++;
+                    ret++;
                 }
                 break;
             }
-
-
         }
+        return ret;
     }
 
     public final DataFlowGraph dfg;
@@ -104,8 +104,10 @@ public class Node {
     public OutPort getOutPort(String name) { return (OutPort)ports.get(name); }
         
     public void build(Context ctx) { for(Port p : ports.values()) p.build(ctx); }
-    public void reset(Context ctx, int phase, Destination ackDestination) {
-        for(Port p : ports.values()) p.reset(ctx, phase, ackDestination);
+    public int reset(Context ctx, int phase, Destination ackDestination) {
+        int ret = 0;
+        for(Port p : ports.values()) ret += p.reset(ctx, phase, ackDestination);
+        return ret;
     }
 
     public abstract class Port {
@@ -116,7 +118,7 @@ public class Node {
             Node.this.ports.put(name,this);
         }
         public abstract void build(Context ctx);
-        public abstract void reset(Context ctx, int phase, Destination ackDestination);
+        public abstract int  reset(Context ctx, int phase, Destination ackDestination);
     }
 
     public abstract class InPort extends Port {
@@ -181,8 +183,8 @@ public class Node {
             for(int i=0; i<pattern.length; i++) if (pattern[i]==null) return true;
             return false;
         }
-        public void reset(Context ctx, int phase, Destination ackDestination) {
-            doReset(ctx, phase, dock, peer, ackDestination, peerUsed());
+        public int reset(Context ctx, int phase, Destination ackDestination) {
+            return doReset(ctx, phase, dock, peer, ackDestination, peerUsed());
         }
         protected void build(Context ctx, LoopFactory lf) {
             int inflight = (count != 0 && count < getInflight()) ? count : getInflight();
@@ -235,8 +237,8 @@ public class Node {
             lf.collectWord();
             peer.sendWord(lf);
         }
-        public void reset(Context ctx, int phase, Destination ackDestination) {
-            doReset(ctx, phase, dock, peer, ackDestination, true);
+        public int reset(Context ctx, int phase, Destination ackDestination) {
+            return doReset(ctx, phase, dock, peer, ackDestination, true);
         }
     }