|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.domains.csp.kernel.AbstractBranchController
ptolemy.domains.csp.kernel.MultiwayBranchController
public class MultiwayBranchController
This controller manages branches for performing multiway rendezvous within the CSP (Communication Sequential Processes) domain. Any CSP actors (either atomic or composite) that multiway rendezvous should contain an instance of this class. In addition, they also needs to implement the BranchActor interface.
The multiway branches are created within the parent actor that contains this controller. The executeBranches() method takes those branches (an array) as an argument, and returns when every branch is successful. A successful branch is a branch that succeeds with its communication. Only branches whose guards are true are enabled. If no branch is enabled, i.e. if all the guards are false, then executeBranches() returns immediately. If exactly one branch is enabled, then the corresponding communication is an ordinary rendezvous. If more than one branch is enabled, a separate thread is created and started for each enabled branch. The executeBranches() method then waits for all of the branches to succeed. When the last branch thread has finished, the method returns, allowing the parent actor thread to continue.
ConditionalBranch
,
BranchActor
,
ConditionalReceive
,
ConditionalSend
Red (bilung) |
Yellow (eal) |
Field Summary | |
---|---|
private java.lang.Thread |
_controllerThread
The controller thread, when it is blocked. |
private boolean |
_failed
Indicator of whether branches were terminated. |
Fields inherited from class ptolemy.domains.csp.kernel.AbstractBranchController |
---|
_branches, _branchesActive, _debugging, _threadList |
Constructor Summary | |
---|---|
MultiwayBranchController(Actor container)
Construct a controller in the specified container, which should be an actor that implements BranchActor. |
Method Summary | |
---|---|
protected void |
_branchFailed(int branchNumber)
Register the calling branch as failed. |
protected void |
_branchNotReady(int branchNumber)
Indicate that the branch is not ready to rendezvous. |
protected void |
_branchSucceeded(int branchID)
Register the calling branch as a successful branch. |
protected boolean |
_isBranchReady(int branchNumber)
Return true if all branches under the control of this controller are ready. |
private void |
_resetConditionalState()
|
boolean |
executeBranches(ConditionalBranch[] branches)
Execute a multiway rendezvous using the specified branches. |
Methods inherited from class ptolemy.domains.csp.kernel.AbstractBranchController |
---|
_branchBlocked, _branchUnblocked, _debug, _getDirector, addDebugListener, getParent, removeDebugListener, terminate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.Thread _controllerThread
private boolean _failed
Constructor Detail |
---|
public MultiwayBranchController(Actor container)
container
- The parent actor that contains this object.Method Detail |
---|
public boolean executeBranches(ConditionalBranch[] branches) throws IllegalActionException
If exactly one branch is enabled, then the communication is performed directly as an ordinary rendezvous. If more than one branch is enabled, a thread is created and started for each enabled branch. These threads try to rendezvous until all succeed.
branches
- The set of branches involved.
IllegalActionException
- If the rendezvous fails
(e.g. because of incompatible types).protected void _branchFailed(int branchNumber)
_branchFailed
in class AbstractBranchController
branchNumber
- The ID assigned to the calling branch
upon creation.protected void _branchNotReady(int branchNumber)
_branchNotReady
in class AbstractBranchController
branchNumber
- The ID assigned to the branch upon creation.protected void _branchSucceeded(int branchID)
_branchSucceeded
in class AbstractBranchController
branchID
- The ID assigned to the calling branch upon creation.protected boolean _isBranchReady(int branchNumber)
_isBranchReady
in class AbstractBranchController
branchNumber
- The ID assigned to the calling branch
upon creation.
private void _resetConditionalState()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |