|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.sim.clock.Synchronizer
The Synchronizer
class represents an object that controls the progress
of a multi-node simulation. The synchronizer preserves the timing and order of events
that influence other nodes' actions (e.g. communication). Since there are multiple
strategies for doing this, this class abstracts the actual mechanism so that clients
can simply create the appropriate synchronizer for their simulation.
Constructor Summary | |
Synchronizer()
|
Method Summary | |
abstract void |
addNode(Simulation.Node n)
The addNode() method adds a node to this synchronization group.
|
abstract 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. |
abstract void |
pause()
The pause() method temporarily pauses the simulation. |
abstract 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. |
abstract 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. |
abstract void |
stop()
The stop() method will terminate all the simulation threads. |
abstract void |
synch(long globalTime)
The synch() method will pause all of the nodes at the same global time.
|
abstract 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 |
Constructor Detail |
public Synchronizer()
Method Detail |
public abstract 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.
n
- the simulator representing the node to add to this grouppublic abstract void removeNode(Simulation.Node n)
removeNode()
method removes a node from this synchronization
group, and wakes any nodes that might be waiting on it.
n
- the simulator thread to remove from this synchronization grouppublic abstract 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.
public abstract 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.
public abstract 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.
java.lang.InterruptedException
public abstract 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.
public abstract 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.
public abstract 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.
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 |