public class RendezvousReceiver extends AbstractReceiver implements ProcessReceiver
Green (tfeng) |
Green (tfeng) |
Constructor and Description |
---|
RendezvousReceiver()
Construct a RendezvousReceiver with no container.
|
RendezvousReceiver(IOPort container)
Construct a RendezvousReceiver with the specified container.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
_commitRendezvous(java.util.Set receivers,
RendezvousDirector director)
Commit the rendezvous formed by the set of receivers that agree to send
and receive at the same time.
|
protected RendezvousDirector |
_getDirector()
Return the director that is controlling the execution of this
model.
|
protected static java.util.Set |
_receiversReadyToCommit(Receiver[][] receivers,
boolean isPut)
Get the receivers that are ready to form a rendezvous according to the
rendezvous semantics.
|
void |
clear()
Reset local flags.
|
Token |
get()
Get a token from this receiver.
|
static Token[][] |
getFromAll(Receiver[][] receivers,
RendezvousDirector director)
Get from all receivers in the specified array.
|
static Token |
getFromAny(Receiver[][] receivers,
RendezvousDirector director)
Get from any receiver in the specified array.
|
static void |
getFromAnyPutToAll(Receiver[][] getReceivers,
Receiver[][] putReceivers,
RendezvousDirector director)
Get from any receiver in the getReceivers array, and put the token
received to all receivers in putReceivers array.
|
boolean |
hasRoom()
Return true.
|
boolean |
hasRoom(int tokens)
Return true.
|
boolean |
hasToken()
Return true.
|
boolean |
hasToken(int tokens)
Return true.
|
boolean |
isConnectedToBoundary()
Return true if this receiver is connected to the inside of a boundary
port.
|
boolean |
isConnectedToBoundaryInside()
Return true if this receiver is connected to the inside of a boundary
port.
|
boolean |
isConnectedToBoundaryOutside()
Return true if this receiver is connected to the outside of a boundary
port.
|
boolean |
isConsumerReceiver()
This class serves as an example of a ConsumerReceiver and hence this
method returns true if this port is connected to a boundary.
|
boolean |
isInsideBoundary()
Return true if this receiver is contained on the inside of a
boundary port.
|
boolean |
isOutsideBoundary()
Return true if this receiver is contained on the outside of a
boundary port.
|
boolean |
isProducerReceiver()
Return true if this receiver is on an outside or an inside boundary.
|
boolean |
isReadBlocked()
Return true if there is a get or a conditional receive waiting on this
receiver.
|
boolean |
isWriteBlocked()
Return true if there is either a put or a conditional send waiting on
this receiver.
|
void |
put(Token token)
Put a token into the mailbox receiver.
|
void |
putArrayToAll(Token[] tokens,
int numberOfTokens,
Receiver[] receivers)
Put a sequence of tokens to all receivers in the specified
array.
|
static void |
putToAll(Token[][] tokens,
Receiver[][] receivers,
RendezvousDirector director)
Put to all receivers in the specified array.
|
void |
putToAll(Token token,
Receiver[] receivers)
Put to all receivers in the specified array.
|
void |
putToAll(Token token,
Receiver[] receivers,
RendezvousDirector director)
Put to all receivers in the specified array.
|
static void |
putToAny(Token token,
Receiver[][] receivers,
RendezvousDirector director)
Put the specified token to any receiver in the specified array.
|
void |
requestFinish()
The model has finished executing, so set a flag so that the
next time an actor tries to get or put it gets a
TerminateProcessException which will cause it to finish.
|
void |
reset()
Reset local flags.
|
static void |
waitForChange(RendezvousDirector director)
Wait on the specified director.
|
elementList, getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, setContainer, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
elementList, getArray, getContainer, isKnown, putArray, setContainer
public RendezvousReceiver()
public RendezvousReceiver(IOPort container) throws IllegalActionException
container
- The port containing this receiver.IllegalActionException
- If this receiver cannot be
contained by the proposed container.public void clear()
clear
in interface Receiver
clear
in class AbstractReceiver
public Token get() throws TerminateProcessException
get
in interface Receiver
get
in class AbstractReceiver
TerminateProcessException
- If the actor to which this
receiver belongs has been terminated while still running i.e it
was not allowed to run to completion.public static Token[][] getFromAll(Receiver[][] receivers, RendezvousDirector director) throws TerminateProcessException
receivers
- The receivers, which are assumed to all be
instances of RendezvousReceiver.director
- The director, on which this method
synchronizes.TerminateProcessException
- If the actor to which this
receiver belongs is to be terminated.public static Token getFromAny(Receiver[][] receivers, RendezvousDirector director) throws TerminateProcessException
receivers
- The receivers, which are assumed to all be
instances of RendezvousReceiver.director
- The director, on which this method
synchronizes.TerminateProcessException
- If the actor to which this
receiver belongs is to be terminated.public static void getFromAnyPutToAll(Receiver[][] getReceivers, Receiver[][] putReceivers, RendezvousDirector director) throws IllegalActionException, TerminateProcessException
getReceivers
- The receivers, which are assumed to all be
instances of RendezvousReceiver, to get tokens from.putReceivers
- The receivers, which are assumed to all be
instances of RendezvousReceiver, to put tokens to.director
- The director, on which this method
synchronizes.IllegalActionException
- If the token is not
acceptable to one of the ports (e.g., wrong type).TerminateProcessException
- If the actor to which this
receiver belongs is to be terminated.public boolean hasRoom()
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
public boolean hasRoom(int tokens)
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
tokens
- Ignored by this method.public boolean hasToken()
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
public boolean hasToken(int tokens)
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
tokens
- Ignored by this method.public boolean isConnectedToBoundary() throws IllegalActionException
isConnectedToBoundary
in interface ProcessReceiver
IllegalActionException
BoundaryDetector
public boolean isConnectedToBoundaryInside() throws InvalidStateException, IllegalActionException
isConnectedToBoundaryInside
in interface ProcessReceiver
IllegalActionException
InvalidStateException
BoundaryDetector
public boolean isConnectedToBoundaryOutside() throws IllegalActionException
isConnectedToBoundaryOutside
in interface ProcessReceiver
IllegalActionException
BoundaryDetector
public boolean isConsumerReceiver() throws IllegalActionException
isConsumerReceiver
in interface ProcessReceiver
IllegalActionException
isConnectedToBoundary()
public boolean isInsideBoundary()
isInsideBoundary
in interface ProcessReceiver
BoundaryDetector
public boolean isOutsideBoundary()
isOutsideBoundary
in interface ProcessReceiver
BoundaryDetector
public boolean isProducerReceiver()
isProducerReceiver
in interface ProcessReceiver
public boolean isReadBlocked()
isReadBlocked
in interface ProcessReceiver
public boolean isWriteBlocked()
isWriteBlocked
in interface ProcessReceiver
public void put(Token token) throws IllegalActionException, TerminateProcessException
put
in interface Receiver
put
in class AbstractReceiver
token
- The token, or null to not put any token.IllegalActionException
- If the token is not
acceptable to the port (e.g., wrong type).TerminateProcessException
- If the actor to which this
receiver belongs has been terminated while still running i.e it
was not allowed to run to completion.public void putArrayToAll(Token[] tokens, int numberOfTokens, Receiver[] receivers) throws NoRoomException, IllegalActionException, TerminateProcessException
putArrayToAll
in interface Receiver
putArrayToAll
in class AbstractReceiver
tokens
- The sequence of token to put.numberOfTokens
- The number of tokens to put (the array might be
longer).receivers
- The receivers.NoRoomException
- If there is no room for the token.IllegalActionException
- If the token is not
acceptable to one of the ports (e.g., wrong type), or if the
tokens array does not have at least the specified number of
tokens.TerminateProcessException
- If the actor to which this
receiver belongs has been terminated while still running i.e it
was not allowed to run to completion.public void putToAll(Token token, Receiver[] receivers) throws NoRoomException, IllegalActionException
putToAll
in interface Receiver
putToAll
in class AbstractReceiver
token
- The token to put, or null to not put any token.receivers
- The receivers.NoRoomException
- If there is no room for the token.IllegalActionException
- If the token is not
acceptable to one of the ports (e.g., wrong type).public void putToAll(Token token, Receiver[] receivers, RendezvousDirector director) throws IllegalActionException, TerminateProcessException
token
- The token to put, or null to not put any token.receivers
- The receivers, which are assumed to all be
instances of RendezvousReceiver.director
- The director, on which this method
synchronizes.IllegalActionException
- If the token is not
acceptable to one of the ports (e.g., wrong type).TerminateProcessException
- If the actor to which this
receiver belongs is to be terminated.public static void putToAll(Token[][] tokens, Receiver[][] receivers, RendezvousDirector director) throws IllegalActionException, TerminateProcessException
tokens
- The tokens to put.receivers
- * The receivers, which are assumed to all be
instances of RendezvousReceiver.director
- The director, on which this method
synchronizes.IllegalActionException
- If the token is not
acceptable to one of the ports (e.g., wrong type).TerminateProcessException
- If the actor to which this
receiver belongs is to be terminated.public static void putToAny(Token token, Receiver[][] receivers, RendezvousDirector director) throws IllegalActionException, TerminateProcessException
token
- The token to put.receivers
- The receivers, which are assumed to all be
instances of RendezvousReceiver.director
- The director, on which this method
synchronizes.IllegalActionException
- If the token is not
acceptable to one of the ports (e.g., wrong type).TerminateProcessException
- If the actor to which this
receiver belongs is to be terminated.public void requestFinish()
requestFinish
in interface ProcessReceiver
public void reset()
reset
in interface ProcessReceiver
reset
in interface Receiver
reset
in class AbstractReceiver
public static void waitForChange(RendezvousDirector director) throws TerminateProcessException
director
- The director on which to wait.TerminateProcessException
- If a finish has been
requested of the specified director, or if the calling thread
is interrupted while waiting.protected static void _commitRendezvous(java.util.Set receivers, RendezvousDirector director)
receivers
- The receivers that participate in the rendezvous.director
- The director._receiversReadyToCommit(Receiver[][], boolean)
protected RendezvousDirector _getDirector()
protected static java.util.Set _receiversReadyToCommit(Receiver[][] receivers, boolean isPut)
receivers
- The array of receivers to be put to or get
from.isPut
- If true, the rendezvous is to put tokens to the
receivers; if false, the rendezvous is to get tokens from the
receivers._commitRendezvous(Set, RendezvousDirector)