Author: mrogers
Date: 2007-06-12 13:46:32 +0000 (Tue, 12 Jun 2007)
New Revision: 13529

Modified:
   trunk/apps/load-balancing-sims/phase7/sim/Event.java
Log:
Make it possible to pause and resume the sim using Event.duration

Modified: trunk/apps/load-balancing-sims/phase7/sim/Event.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Event.java        2007-06-12 
08:03:45 UTC (rev 13528)
+++ trunk/apps/load-balancing-sims/phase7/sim/Event.java        2007-06-12 
13:46:32 UTC (rev 13529)
@@ -31,12 +31,15 @@
        {
                try {
                        Event e = queue.first();
-                       queue.remove (e);
+                       // Return if the simulation's alloted time has run out
+                       if (e.time > duration) {
+                               now = duration;
+                               return false;
+                       }
                        // Update the clock
                        now = e.time;
-                       // Quit if the simulation's alloted time has run out
-                       if (now > duration) return false;
                        // Pass the packet to the target's callback method
+                       queue.remove (e);
                        e.target.handleEvent (e.type, e.data);
                        return true;
                }
@@ -65,7 +68,7 @@
                while (nextEvent()) {}
        }

-       // Non-static variables and methods for individual events
+       // Instance variables and methods for individual events

        private EventTarget target;
        private double time;


Reply via email to