|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.domains.csp.kernel.ConditionalBranch
Base class for classes representing guarded communication statements. A guarded communication statement is of the form
If the guard is true, or absent which implies true, then the branch is enabled. Guarded communication statements are used to perform both forms of conditional communication constructs: "conditional if" (CIF) and "conditional do" (CDO). These constructs are analogous to, but different from, the common if and do statements. Each guarded communication statement is one branch of a CIF or CDO.
A CDO has the form
CDO {
G1; C1 => S1;
[]
G2; C2 => S2;
[]
...
}
The G1, G2 etc. represent the guards. The C1, C2 etc. represent the communication associated with that branch, and may be either a send() or a get(). The S1, S2 etc. represent the blocks of statements associated with that branch. They are executed if that branch is successful. The "[]" hints at the fact that the guards are all evaluated in parallel (as opposed to sequentially in a common if statement).
While at least one of the branches is enabled, the construct continues to evaluate and execute one of the enabled branches. If more than one branch is enabled, the first branch to be able to rendezvous succeeds and its statements are executed. Note that this construct is nondeterministic as it may be a race condition that determines which branch is successful. The CIF is similar to the CDO except that it is only evaluated once.
The communication part of a guarded communication statement can be either a send() or a get(). There are thus two subclasses of this class, each representing a guarded communication statement for one of the communication primitives. The subclasses are ConditionalSend and ConditionalReceive.
If more than one branch is enabled, each enabled branch is executed in a separate thread. For rendezvous, the receiver is the key synchronization point.
Conditional branches are designed to be used once. Upon instantiation, they are given the guard, the port and channel over which to communicate, and the identification number of the branch according to the controller. The port and the channel together define the CSPReceiver with which to rendezvous. The ConditionalBranchController, that controls this branch, is assumed to be contained by the container of the port.
| Green (kienhuis) |
| Green (nsmyth) |
| Field Summary | |
protected boolean |
_guard
|
| Constructor Summary | |
ConditionalBranch(boolean guard,
IOPort port,
int branchID)
Create a guarded communication statement. |
|
ConditionalBranch(boolean guard,
IOPort port,
int branchID,
ConditionalBranchController cbc)
Create a guarded communication statement. |
|
| Method Summary | |
ConditionalBranchController |
getController()
Return the controller that manges conditional rendezvous for this branch when performing a CIF or CDO. |
boolean |
getGuard()
Returns the guard for this guarded communication statement. |
int |
getID()
Returns the identification number of this branch(according to its controller). |
CSPReceiver |
getReceiver()
Return the CSPReceiver this branch is trying to rendezvous with. |
Token |
getToken()
Return the token contained by this branch. |
boolean |
isAlive()
Boolean indicating if this branch is still alive. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected boolean _guard
| Constructor Detail |
public ConditionalBranch(boolean guard,
IOPort port,
int branchID)
throws IllegalActionException
guard - The guard for the guarded communication statement
represented by this object.port - The IOPort that contains the channel to
try an communicate through.branchID - The identification number assigned to this branch
upon creation by the CSPActor.
IllegalActionException - If the actor that contains
the port is not of type CSPActor.
public ConditionalBranch(boolean guard,
IOPort port,
int branchID,
ConditionalBranchController cbc)
throws IllegalActionException
guard - The guard for the guarded communication statement
represented by this object.port - The IOPort that contains the channel to
try an communicate through.branchID - The identification number assigned to this branch
upon creation by the CSPActor.cbc - The ConditionalBranchController associated with this branch.
IllegalActionException - If the actor that contains
the port is not of type CSPActor.| Method Detail |
public boolean getGuard()
public int getID()
public ConditionalBranchController getController()
public CSPReceiver getReceiver()
public Token getToken()
public boolean isAlive()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||