public class Branch
extends java.lang.Object
implements java.lang.Runnable
During its execution a branch attempts to get data from the producer receiver and put data in the consumer receiver. The communication semantics of the producer receiver get() method are dependent upon the model of computation associated with the producer receiver. In cases where a blocking read occurs, the producer receiver registers the block with the calling branch leading to a blocked branch. So that the producer receiver knows which branch to register the block with, a branch always invokes the receiver's get() method by passing itself as an argument. A blocked branch registers the block with the branch controller that it is assigned to.
Putting data in a consumer receiver is symmetrically analogous to getting data from a producer receiver. In cases where a blocking write occurs, the consumer receiver registers the block with the calling branch leading to a blocked branch. So that the consumer receiver knows which branch to register the block with, a branch always invokes the receiver's put() method by passing itself as an argument.
Constructor and Description |
---|
Branch(BranchController controller)
Deprecated.
Use this constructor for testing purposes only.
|
Branch(ProcessReceiver producerReceiver,
ProcessReceiver consumerReceiver,
BranchController controller)
Construct a branch object with a producer receiver, a consumer
receiver and a branch controller.
|
Modifier and Type | Method and Description |
---|---|
ProcessReceiver |
getConsumerReceiver()
Return the consumer receiver that this branch puts data into.
|
ProcessReceiver |
getProducerReceiver()
Return the producer receiver that this branch gets data from.
|
boolean |
isActive()
Return true if this branch is active.
|
void |
run()
Repeatedly transfer a single token between the producer
receiver and the consumer receiver as long as the branch
is active or until a TerminateProcessException is thrown.
|
void |
setActive(boolean value)
Set a flag indicating this branch is no longer active.
|
void |
transferToken()
Transfer a single token from the producer receiver to the
consumer receiver.
|
@Deprecated public Branch(BranchController controller) throws IllegalActionException
controller
- The branch controller assigned to this branch.IllegalActionException
- Not thrown in this base class.public Branch(ProcessReceiver producerReceiver, ProcessReceiver consumerReceiver, BranchController controller) throws IllegalActionException
producerReceiver
- The producer receiver assigned to this branch.consumerReceiver
- The consumer receiver assigned to this branch.controller
- The branch controller assigned to this branch.IllegalActionException
- If the receivers assigned to
this branch are null or improperly configured.public ProcessReceiver getConsumerReceiver()
BoundaryDetector
public ProcessReceiver getProducerReceiver()
BoundaryDetector
public boolean isActive()
public void run()
run
in interface java.lang.Runnable
public void setActive(boolean value)
value
- A boolean indicating whether this branch is
still active.public void transferToken() throws IllegalActionException
IllegalActionException
- If the token is not acceptable
to one of the ports (e.g., wrong type).