|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.actor.AbstractReceiver
ptolemy.domains.sdf.kernel.SDFReceiver
public class SDFReceiver
A first-in, first-out (FIFO) queue receiver with variable capacity and optional history. Tokens are put into the receiver with the put() method, and removed from the receiver with the get() method. The token removed is the one placed in the receiver before any other (i.e. the "oldest", although this has nothing to do with time in the model. By default, the capacity is unbounded, but it can be set to any nonnegative size. If the history capacity is greater than zero (or infinite, indicated by a capacity of INFINITE_CAPACITY), then tokens removed from the receiver are stored in a history queue rather than simply removed. By default, the history capacity is zero.
ArrayFIFOQueue
Green (neuendor) |
Green (neuendor) |
Field Summary | |
---|---|
private ArrayFIFOQueue |
_queue
|
private Token[] |
_tokenArray
|
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 Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class ptolemy.actor.AbstractReceiver |
---|
getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, reset, setContainer, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INFINITE_CAPACITY
public int _waitingTokens
private ArrayFIFOQueue _queue
private Token[] _tokenArray
Constructor Detail |
---|
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.Method Detail |
---|
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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |