|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.sim.clock.Synchronizer avrora.sim.clock.StepSynchronizer
The StepSynchronizer
class is an implementation of simulator synchronization
that steps each node one cycle at a time using the Simulator.step()
method
of each simulator.
Nested Class Summary | |
protected class |
StepSynchronizer.RunThread
The RunThread class implements a thread that runs the simulation, to preserve
the model that the thread interacting with the synchronizer through calls to
start() , stop(), etc. is different than any of the
threads running actual simulator code. |
Field Summary | |
protected Simulator.Event |
action
|
protected boolean |
innerLoop
|
protected int |
numThreads
|
protected boolean |
shouldRun
|
protected StepSynchronizer.RunThread |
thread
|
protected Simulator[] |
threads
|
Constructor Summary | |
StepSynchronizer(Simulator.Event e)
The constructor for the StepSynchronizer class creates a new instance
of this synchronizer. |
Method Summary | |
void |
addNode(Simulation.Node n)
The addNode() method adds a node to this synchronization group.
|
void |
join()
The join() method will block the caller until all of the threads in
this synchronization interval have terminated, either through stop()
being called, or terminating normally such as through a timeout. |
void |
pause()
The pause() method temporarily pauses the simulation. |
void |
removeNode(Simulation.Node n)
The removeNode() method removes a node from this synchronization
group, and wakes any nodes that might be waiting on it. |
void |
start()
The start() method starts the threads executing, and the synchronizer
will add whatever synchronization to their execution that is necessary to preserve
the global timing properties of simulation. |
void |
stop()
The stop() method will terminate all the simulation threads. |
void |
synch(long globalTime)
The synch() method will pause all of the nodes at the same global time.
|
void |
waitForNeighbors(long time)
The waitForNeighbors() method is called from within the execution
of a node when that node needs to wait for its neighbors to catch up to it
in execution time. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final Simulator.Event action
protected Simulator[] threads
protected int numThreads
protected boolean shouldRun
protected boolean innerLoop
protected StepSynchronizer.RunThread thread
Constructor Detail |
public StepSynchronizer(Simulator.Event e)
StepSynchronizer
class creates a new instance
of this synchronizer. The event passed as a parameter will be fired after each iteration;
i.e. when all nodes have been stepped one clock cycle.
e
- the event to fire after each step of the simulationMethod Detail |
public void addNode(Simulation.Node n)
addNode()
method adds a node to this synchronization group.
This method should only be called before the start()
method is
called.
addNode
in class Synchronizer
n
- the simulator representing the node to add to this grouppublic void removeNode(Simulation.Node n)
removeNode()
method removes a node from this synchronization
group, and wakes any nodes that might be waiting on it.
removeNode
in class Synchronizer
n
- the simulator thread to remove from this synchronization grouppublic void waitForNeighbors(long time)
waitForNeighbors()
method is called from within the execution
of a node when that node needs to wait for its neighbors to catch up to it
in execution time. The node will be blocked until the other nodes in other
threads catch up in global time.
waitForNeighbors
in class Synchronizer
public void start()
start()
method starts the threads executing, and the synchronizer
will add whatever synchronization to their execution that is necessary to preserve
the global timing properties of simulation.
start
in class Synchronizer
public void join() throws java.lang.InterruptedException
join()
method will block the caller until all of the threads in
this synchronization interval have terminated, either through stop()
being called, or terminating normally such as through a timeout.
join
in class Synchronizer
java.lang.InterruptedException
public void pause()
pause()
method temporarily pauses the simulation. The nodes are
not guaranteed to stop at the same global time. This method will return when all
threads in the simulation have been paused and will no longer make progress until
the start()
method is called again.
pause
in class Synchronizer
public void stop()
stop()
method will terminate all the simulation threads. It is
not guaranteed to stop all the simulation threads at the same global time.
stop
in class Synchronizer
public void synch(long globalTime)
synch()
method will pause all of the nodes at the same global time.
This method can only be called when the simulation is paused. It will run all threads
forward until the global time specified and pause them.
synch
in class Synchronizer
globalTime
- the global time in clock cycles to run all threads ahead to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |