|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.domains.csp.kernel.ConditionalBranchController
A controller that manages the conditional branches for performing conditional communication within CSP (Communication Sequential Processes) domain. Any CSP actors (either atomic or composite) that need the functionality of conditional communication must contain and instantiate an object of this class. In addition, they also needs to implement the interface ConditionalBranchActor.
The conditional branches are supposed to be created within the parent actor that contains this controller.
The chooseBranch() method takes those branches (an array) as an argument, and controls which branch is successful. The successful branch is the branch that succeeds with its communication. To determine which branch is successful, the guards of all branches are checked. If the guard for a branch is true then that branch is enabled. If no branches are enabled, i.e. if all the guards are false, then -1 is returned to indicate this. If exactly one branch is enabled, the corresponding communication is carried out and the identification number of the branch is returned. If more than one branch is enabled, a separate thread is created and started for each enabled branch. The method then waits for one of the branches to succeed, after which it wakes up and terminates the remaining branches. When the last conditional branch thread has finished, the method returns allowing the parent actor thread to continue.
ConditionalBranch,
ConditionalBranchActor,
ConditionalReceive,
ConditionalSend
| Red (bilung) |
| Red (bilung) |
| Constructor Summary | |
ConditionalBranchController(Actor container)
Construct a controller in the specified container, which should be an actor. |
|
| Method Summary | |
protected void |
_branchBlocked(CSPReceiver receiver)
Increase the count of branches that are blocked trying to rendezvous. |
protected void |
_branchFailed(int branchNumber)
Registers the calling branch as failed. |
protected void |
_branchSucceeded(int branchID)
Registers the calling branch as the successful branch. |
protected void |
_branchUnblocked(CSPReceiver receiver)
Decrease the count of branches that are read blocked. |
protected boolean |
_isBranchFirst(int branchNumber)
Called by ConditionalSend and ConditionalReceive to check if the calling branch is the first branch to be ready to rendezvous. |
protected void |
_releaseFirst(int branchNumber)
Release the status of the calling branch as the first branch to be ready to rendezvous. |
int |
chooseBranch(ConditionalBranch[] branches)
Determine which branch succeeds with a rendezvous. |
Actor |
getParent()
Return the Actor that creates the branch and owns this controller when performing a CIF or CDO. |
void |
terminate()
Terminate abruptly any threads created by this actor. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ConditionalBranchController(Actor container)
container - The parent actor that contains this object.| Method Detail |
public int chooseBranch(ConditionalBranch[] branches)
If exactly one branch is enabled, then the communication is performed directly and the id of the enabled branch is returned. If more than one branch is enabled, a thread is created and started for each enabled branch. These threads try to rendezvous until one succeeds. After a thread succeeds the other threads are killed, and the id of the successful branch is returned.
branches - The set of conditional branches involved.
public Actor getParent()
public void terminate()
protected boolean _isBranchFirst(int branchNumber)
branchNumber - The ID assigned to the calling branch
upon creation.
protected void _branchBlocked(CSPReceiver receiver)
protected void _branchFailed(int branchNumber)
branchNumber - The ID assigned to the calling branch
upon creation.protected void _branchSucceeded(int branchID)
branchID - The ID assigned to the calling branch upon creation.protected void _branchUnblocked(CSPReceiver receiver)
protected void _releaseFirst(int branchNumber)
branchNumber - The ID assigned to the branch upon creation.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||