add extratokens option to shutdown code
authoradam <adam@megacz.com>
Mon, 17 Nov 2008 01:25:15 +0000 (02:25 +0100)
committeradam <adam@megacz.com>
Mon, 17 Nov 2008 01:25:15 +0000 (02:25 +0100)
src/edu/berkeley/fleet/ir/Process.java

index bb29b3e..4087064 100644 (file)
@@ -215,6 +215,10 @@ public class Process {
                 peer.sendWord(lf);
             }
             public void reset(Context ctx, int phase) {
+
+                // set this to true to get a more "fine grained" report of the shutdown process
+                boolean extratokens = false;
+
                 switch(phase) {
                     case 0: {
                         torpedoes.add(dock);
@@ -222,13 +226,14 @@ public class Process {
                     }
                     case 1: {
                         Context.LoopFactory lf = ctx.new LoopFactory(dock, 1);
-                        lf.sendToken(fleet.getShip("Debug",0).getDock("in").getDataDestination());
                         if (peer != null) {
                             for(int i=0; i<peer.getTokensToAbsorb(); i++) {
                                 lf.recvToken();
+                                if (extratokens) lf.sendToken(fleet.getShip("Debug",0).getDock("in").getDataDestination());
                             }
                             //lf.sendToken(dip_peer.dock.getInstructionDestination());
                         }
+                        lf.sendToken(fleet.getShip("Debug",0).getDock("in").getDataDestination());
                         lf = lf.makeNext(0);
                         lf.abortLoopIfTorpedoPresent();
                         lf.collectWord();
@@ -236,6 +241,7 @@ public class Process {
                     }
                     case 2: {
                         reset_count++;
+                        if (extratokens && peer != null) reset_count += peer.getTokensToAbsorb();
                         break;
                     }
                     case 3: {