|
|||||||||
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.dde.kernel.PrioritizedTimedQueue
ptolemy.domains.dde.kernel.DDEReceiver
public class DDEReceiver
A DDEReceiver stores time stamped tokens according to distributed discrete event semantics. A time stamped token is a token that has a time stamp associated with it. A DDEReceiver stores time stamped tokens by enforcing a blocking read and blocking write style. Time stamped tokens are appended to the queue with one of the two put() methods, both of which block on a write if the queue is full. Time stamped tokens are removed from the queue via the get() method. The get() method will throw a NoTokenException if it is invoked when the hasToken() method returns false.
Each DDEReceiver is managed by a TimeKeeper. A single time keeper is assigned to manage all of the receivers of a given actor by keeping track of the actor's local notion of time. As tokens are consumed (returned by the get() method) in a receiver, the local time of the actor will advance to the value of the consumed token's time stamp. The hasToken() method of a receiver will return true only if the receiver's get() method will result in the minimum advancement of local time with respect to all of the receivers controlled by the TimeKeeper. If the get() method of multiple receivers will result in a minimum but identical local time advancement, then the hasToken() method of the receiver with the highest priority will return true (the others will return false).
If a receiver with a nonnegative receiver time is empty, then the hasToken() method will perform a blocking read. Once, a token is available then hasToken() will return true or false according to the minimum time advancement rules cited in the preceding paragraph. Note that hasToken() blocks while get() does not block.
DDEReceivers process certain events that are hidden from view by ports and actors. In particular, NullTokens have time stamps with a value of PrioritizedTimedQueue.IGNORE. NullTokens allow actors to communicate information on their local time advancement to neighboring actors without the need for an actual data exchange. NullTokens are passed at the receiver level and circumvent the Ptolemy II data typing mechanism.
Time stamps of value PrioritizedTimedQueue.IGNORE are used to initiate execution in feedback cycles. If a receiver has a time stamp with value IGNORE, then it will not be considered when determining which receiver's get() method will result in the minimum local time advancement. Once a single token has been consumed by any other receiver, then the event with time stamp of value IGNORE will be removed. If all receivers have receiver times of IGNORE, then all such events will be removed.
IMPORTANT: This class assumes that valid time stamps have non-negative values. Reserved negative values exist for special purposes: INACTIVE and IGNORE. These values are attributes of PrioritizedTimedQueue.
PrioritizedTimedQueue
,
DDEThread
Green (kienhuis) |
Green (davisj) |
Field Summary | |
---|---|
private BoundaryDetector |
_boundaryDetector
The boundary detector. |
private DDEDirector |
_director
The director in charge of this receiver. |
private boolean |
_hasTokenCache
Indicator of the result of the most recent call to hasToken(). |
private boolean |
_hideNullTokens
|
private java.lang.Thread |
_readPending
Reference to a thread that is read blocked on this receiver. |
private boolean |
_terminate
Flag indicating that termination has been requested. |
private java.lang.Thread |
_writePending
Reference to a thread that is write blocked on this receiver. |
Fields inherited from class ptolemy.domains.dde.kernel.PrioritizedTimedQueue |
---|
_lastTime, _priority, ETERNITY, IGNORE, INACTIVE |
Constructor Summary | |
---|---|
DDEReceiver()
Construct an empty receiver with no container. |
|
DDEReceiver(IOPort container)
Construct an empty receiver with the specified container. |
|
DDEReceiver(IOPort container,
int priority)
Construct an empty receiver with the specified IOPort container and priority. |
Method Summary | |
---|---|
(package private) void |
_hideNullTokens(boolean hide)
Indicate whether hasToken() should return true if the only available tokens it finds are NullTokens. |
void |
clear()
Clear this receiver of any contained tokens. |
Token |
get()
Get a token from the mailbox receiver. |
DDEDirector |
getDirector()
Return the director in charge of this receiver, or null if there is none. |
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 the get() method of this receiver will return a token without throwing a NoTokenException. |
boolean |
hasToken(int tokens)
Return true if the receiver contains the given number of tokens that can be obtained by calling the get() method. |
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()
Return true if this receiver is a consumer receiver. |
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 a producer receiver. |
boolean |
isReadBlocked()
Return a true or false to indicate whether there is a read block on this receiver or not, respectively. |
boolean |
isWriteBlocked()
Return a true or false to indicate whether there is a write block on this receiver or not. |
void |
put(Token token)
Do a blocking write on the queue. |
void |
put(Token token,
Time time)
Do a blocking write on the queue. |
void |
requestFinish()
Schedule this receiver to terminate. |
void |
reset()
Reset local flags. |
void |
setContainer(IOPort port)
Set the container. |
Methods inherited from class ptolemy.domains.dde.kernel.PrioritizedTimedQueue |
---|
_getCompletionTime, _hasNullToken, _setCompletionTime, _setReceiverTime, elementList, getCapacity, getLastTime, getReceiverTime, hasRoom, removeIgnoredToken, setCapacity |
Methods inherited from class ptolemy.actor.AbstractReceiver |
---|
getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.Receiver |
---|
elementList, getArray, getContainer, hasRoom, isKnown, putArray, putArrayToAll, putToAll |
Field Detail |
---|
private BoundaryDetector _boundaryDetector
private DDEDirector _director
private boolean _hasTokenCache
private java.lang.Thread _readPending
private boolean _terminate
private java.lang.Thread _writePending
private boolean _hideNullTokens
Constructor Detail |
---|
public DDEReceiver()
public DDEReceiver(IOPort container) throws IllegalActionException
container
- The IOPort that contains this receiver.
IllegalActionException
- If this receiver cannot be
contained by the proposed container.public DDEReceiver(IOPort container, int priority) throws IllegalActionException
container
- The IOPort that contains this receiver.priority
- The priority of this receiver.
IllegalActionException
- If this receiver cannot be
contained by the proposed container.Method Detail |
---|
public void clear()
clear
in interface Receiver
clear
in class AbstractReceiver
public Token get()
get
in interface Receiver
get
in class PrioritizedTimedQueue
NoTokenException
- If there is no token.public DDEDirector getDirector()
public boolean hasRoom(int tokens)
hasRoom
in interface Receiver
hasRoom
in class PrioritizedTimedQueue
tokens
- The number of tokens to put into the queue.
public boolean hasToken()
If at any point during this method this receiver is scheduled for termination, then throw a TerminateProcessException to cease execution of the actor that contains this receiver.
hasToken
in interface Receiver
hasToken
in class PrioritizedTimedQueue
public boolean hasToken(int tokens)
hasToken
in interface Receiver
hasToken
in class PrioritizedTimedQueue
tokens
- The number of tokens to get from the queue.
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
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)
put
in interface Receiver
put
in class PrioritizedTimedQueue
token
- The token to put in the queue, or null to put no token.
TerminateProcessException
- If activity is scheduled
to cease.public void put(Token token, Time time)
put
in class PrioritizedTimedQueue
token
- The token to put in the queue, or null to put no token.time
- The specified time stamp.
TerminateProcessException
- If activity is scheduled
to cease.public void requestFinish()
requestFinish
in interface ProcessReceiver
public void reset()
reset
in interface ProcessReceiver
reset
in interface Receiver
reset
in class PrioritizedTimedQueue
public void setContainer(IOPort port) throws IllegalActionException
setContainer
in interface Receiver
setContainer
in class AbstractReceiver
port
- The container.
IllegalActionException
- If the container is not of
an appropriate subclass of IOPort, or if the container's director
is not an instance of DDEDirector.AbstractReceiver.getContainer()
void _hideNullTokens(boolean hide)
hide
- The parameter indicating whether NullTokens
should be taken into consideration by hasToken().
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |