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, toString
protected 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 Receiver
clear
in class AbstractReceiver
public java.util.List<Token> elementList()
elementList
in interface Receiver
elementList
in class AbstractReceiver
public Token get() throws NoTokenException
get
in interface Receiver
get
in class AbstractReceiver
NoTokenException
- 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 Receiver
hasRoom
in class AbstractReceiver
public boolean hasRoom(int tokens)
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
tokens
- An int indicating the number of spaces available.public boolean hasToken()
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
public boolean hasToken(int numberOfTokens)
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
numberOfTokens
- An int indicating how many tokens are needed.public void put(Token token) throws IllegalActionException
put
in interface Receiver
put
in class AbstractReceiver
token
- The token to be put, or null to put no token.IllegalActionException
- If cannot get the director or if
the current microstep is zero.