public class MultiwayBranchController extends AbstractBranchController
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
_branches, _branchesActive, _debugging, _threadList
Constructor and Description |
---|
MultiwayBranchController(Actor container)
Construct a controller in the specified container, which should
be an actor that implements BranchActor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
executeBranches(ConditionalBranch[] branches)
Execute a multiway rendezvous using the specified branches.
|
_branchBlocked, _branchUnblocked, _debug, _getDirector, addDebugListener, getParent, removeDebugListener, terminate
public MultiwayBranchController(Actor container)
container
- The parent actor that contains this object.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.