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. @author Neil Smyth, Bilung Lee, Edward A. Lee @version $Id: ConditionalBranchController.java,v 1.55 2006/03/30 16:35:46 cxh Exp $ @since Ptolemy II 0.4 @Pt.ProposedRating Yellow (eal) @Pt.AcceptedRating Red (bilung) @see ConditionalBranch @see BranchActor @see ConditionalReceive @see ConditionalSend
|
|