|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvisidia.simulation.process.algorithm.Algorithm
visidia.simulation.process.algorithm.SynchronousAlgorithm
public abstract class SynchronousAlgorithm
This is the abstract base class representing a synchronous algorithm in visidia.
It is the API to be used to implement new synchronous algorithms (extending SynchronousAlgorithm class).
A synchronous algorithm (written by the user) must have the following
skeleton
BEGIN
FOR EVERY PHASE i DO:
1 * actions to do in phase i :
action 0 : ...
action 1 : ...
...
action k : sendTo(...) receive(...) getMsg...(...), anyMsg...(),
putProperty() ... ... ;
...
...
final action :
2 * nextPulse(); // the nodes declares that he has finished the actions to do
in phase i
// it is blocked until all other nodes have finished their
actions in phase i
// if the node v does not declare the end of its
current phase then all other nodes
// will be blocked until the node v
execute the nextPulse() method.
// the receive method automatically
execute the nextPulse() method if no message
// have been found.
END DO
END
The main task of this class when sending a message is to set the
message clock with the value returned by the getPulse method of
class Algorithm.
the receive(...) and getMsg...(...) methods are more sophisticated and
the user should take a look. Note that he can always do without by using the
existMessage(...) and getMessage(...) methods of class SyncAlgorithm
Field Summary |
---|
Fields inherited from class visidia.simulation.process.algorithm.Algorithm |
---|
proc |
Constructor Summary | |
---|---|
SynchronousAlgorithm()
|
Method Summary | |
---|---|
protected boolean |
anyMsg()
return true if the node has received any message which has been sent in the previous pulse |
protected boolean |
existMessage(DoorPulseCriterion dpc)
return true if there exists a message that matches the dpc criterion in the message queue of the node. |
protected Message |
getNextMessage(DoorPulseCriterion dpc)
The most general and powerful method to handle reception of messages. |
int |
getPulse()
Gets the current pulse. |
int |
nextPulse()
Make the node calling this function finish it's pulse. |
protected Message |
receive(Door door)
return the first message arrived in the previous pulse and write the door number in the Door object. |
protected boolean |
sendTo(int door,
Message msg)
Send the message message on target door. |
Methods inherited from class visidia.simulation.process.algorithm.Algorithm |
---|
clone, getArity, getDescription, getEdgeProperty, getId, getMessageTypeList, getNetSize, getOrientedDoors, getProperty, init, isIncomingDoor, isOutgoingDoor, putProperty, putProperty, receiveFrom, receiveFrom, run, sendAll, setDoorState, setEdgeProperty, setMessageProcess |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SynchronousAlgorithm()
Method Detail |
---|
public final int getPulse()
public final int nextPulse()
protected boolean sendTo(int door, Message msg)
sendTo
in class Algorithm
door
- the doormsg
- the message
protected final Message getNextMessage(DoorPulseCriterion dpc)
protected final Message receive(Door door)
receive
in class Algorithm
door
- the door
protected final boolean existMessage(DoorPulseCriterion dpc)
protected final boolean anyMsg()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |