public class DEReceiver extends AbstractReceiver
The put() method stores the given token in this receiver and posts a trigger event to the director. The director is responsible to dequeue that trigger event and invoke the actor that contains this receiver. The get() method returns the first available token from the receiver.
Before firing an actor, the director is expected to put at least one token into at least one of the receivers contained by the actor.
| Yellow (hyzheng) |
| Green (hyzheng) |
| Modifier and Type | Field and Description |
|---|---|
protected long |
_directorVersion
The version of the workspace of container, used for
caching by _getDirector().
|
protected java.util.LinkedList |
_tokens
List for storing tokens.
|
| Constructor and Description |
|---|
DEReceiver()
Construct an empty DEReceiver with no container.
|
DEReceiver(IOPort container)
Construct an empty DEReceiver with the specified container.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear this receiver of any contained tokens.
|
java.util.List<Token> |
elementList()
Return a list with tokens that are currently in the receiver
available for get() or getArray(), beginning with the oldest one.
|
Token |
get()
Get the first token from the receiver.
|
boolean |
hasRoom()
Return true, indicating that there is always room.
|
boolean |
hasRoom(int tokens)
Return true if the receiver has room for putting the given number of
tokens into it (via the put() method).
|
boolean |
hasToken()
Return true if there is at least one token available to the
get() method.
|
boolean |
hasToken(int numberOfTokens)
Return true if there are numberOfTokens
tokens tokens available to the get() method.
|
void |
put(Token token)
Put a token into this receiver and post a trigger event to the director.
|
getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, reset, setContainer, toStringprotected long _directorVersion
protected java.util.LinkedList _tokens
public DEReceiver()
public DEReceiver(IOPort container) throws IllegalActionException
container - The container.IllegalActionException - If the container does
not accept this receiver.public void clear()
clear in interface Receiverclear in class AbstractReceiverpublic java.util.List<Token> elementList()
elementList in interface ReceiverelementList in class AbstractReceiverpublic Token get() throws NoTokenException
get in interface Receiverget in class AbstractReceiverNoTokenException - If there are no more tokens. This is
a runtime exception, so it need not to be declared explicitly.public final boolean hasRoom()
hasRoom in interface ReceiverhasRoom in class AbstractReceiverpublic boolean hasRoom(int tokens)
hasRoom in interface ReceiverhasRoom in class AbstractReceivertokens - An int indicating the number of spaces available.public boolean hasToken()
hasToken in interface ReceiverhasToken in class AbstractReceiverpublic boolean hasToken(int numberOfTokens)
hasToken in interface ReceiverhasToken in class AbstractReceivernumberOfTokens - An int indicating how many tokens are needed.public void put(Token token) throws IllegalActionException
put in interface Receiverput in class AbstractReceivertoken - The token to be put, or null to put no token.IllegalActionException - If cannot get the director or if
the current microstep is zero.