public class SDFReceiver extends AbstractReceiver
ArrayFIFOQueue
Modifier and Type | Field and Description |
---|---|
int |
_waitingTokens
The number of tokens waiting to be consumed during scheduling.
|
static int |
INFINITE_CAPACITY
A constant indicating that the capacity of the receiver is
unbounded.
|
Constructor and Description |
---|
SDFReceiver()
Construct an empty receiver with no container.
|
SDFReceiver(int size)
Construct an empty receiver with no container and given size.
|
SDFReceiver(IOPort container)
Construct an empty receiver with the specified container.
|
SDFReceiver(IOPort container,
int size)
Construct an empty receiver with the specified container and size.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear this receiver of any contained tokens.
|
java.util.List<Token> |
elementList()
Return a list with the tokens currently in the receiver, or
an empty list if there are no such tokens.
|
Token |
get()
Remove the first token (the oldest one) from the receiver and
return it.
|
Token |
get(int offset)
Return a token in the receiver or its history.
|
Token[] |
getArray(int count)
Get an array of tokens from this receiver.
|
int |
getCapacity()
Return the capacity, or INFINITE_CAPACITY if it is unbounded.
|
int |
getHistoryCapacity()
Return the capacity of the history queue.
|
boolean |
hasRoom()
Return true if put() will succeed in accepting a token.
|
boolean |
hasRoom(int tokens)
Return true if put() will succeed in accepting the specified
number of tokens.
|
boolean |
hasToken()
Return true if get() will succeed in returning a token.
|
boolean |
hasToken(int tokens)
Return true if get() will succeed in returning a token the given
number of times.
|
java.util.Enumeration |
historyElements()
Enumerate the tokens stored in the history queue, which are
the N most recent tokens taken from the receiver, beginning with
the oldest, where N is less than or equal to the history capacity.
|
int |
historySize()
Return the number of tokens in history.
|
void |
put(Token token)
Put a token to the receiver.
|
void |
setCapacity(int capacity)
Set receiver capacity.
|
void |
setHistoryCapacity(int capacity)
Set the capacity of the history queue.
|
int |
size()
Return the number of tokens in the receiver.
|
getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, reset, setContainer, toString
public static final int INFINITE_CAPACITY
public int _waitingTokens
public SDFReceiver()
public SDFReceiver(int size)
size
- The size of the queue in the receiver.public SDFReceiver(IOPort container) throws IllegalActionException
container
- The container of the receiver.IllegalActionException
- If the container does
not accept this receiver.public SDFReceiver(IOPort container, int size) throws IllegalActionException
container
- The container of the receiver.size
- The size of the queue in the receiver.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()
get
in interface Receiver
get
in class AbstractReceiver
NoTokenException
- If there is no token in the receiver.public Token get(int offset)
offset
- The offset from the oldest token in the receiver.NoTokenException
- If the offset is out of range.public Token[] getArray(int count)
getArray
in interface Receiver
getArray
in class AbstractReceiver
count
- The number of valid tokens to get in the
returned array.NoTokenException
- If there are not count
tokens.public int getCapacity()
setCapacity(int)
public int getHistoryCapacity()
historyElements()
,
historySize()
,
setHistoryCapacity(int)
public boolean hasRoom()
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
public boolean hasRoom(int tokens) throws java.lang.IllegalArgumentException
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
tokens
- The number of tokens.java.lang.IllegalArgumentException
- If the argument is less
than one. This is a runtime exception, so it need not be
declared explicitly by the caller.public boolean hasToken()
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
public boolean hasToken(int tokens) throws java.lang.IllegalArgumentException
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
tokens
- The number of tokens.java.lang.IllegalArgumentException
- If the argument is less
than one. This is a runtime exception, so it need not be
declared explicitly by the caller.public java.util.Enumeration historyElements()
getHistoryCapacity()
,
historySize()
,
setHistoryCapacity(int)
public int historySize()
getHistoryCapacity()
,
historyElements()
,
setHistoryCapacity(int)
public void put(Token token)
put
in interface Receiver
put
in class AbstractReceiver
token
- The token to be put to the receiver, or null to
not put any token.NoRoomException
- If the receiver is full.public void setCapacity(int capacity) throws IllegalActionException
capacity
- The desired receiver capacity.IllegalActionException
- If the receiver has more tokens
than the proposed capacity or the proposed capacity is illegal.getCapacity()
public void setHistoryCapacity(int capacity) throws IllegalActionException
capacity
- The desired history capacity.IllegalActionException
- If the desired capacity is illegal.getHistoryCapacity()
,
historyElements()
,
historySize()
public int size()