|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.actor.AbstractReceiver
ptolemy.domains.dde.kernel.PrioritizedTimedQueue
ptolemy.domains.dde.kernel.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) |
| 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 | |
void |
clear()
Clear this receiver of any contained tokens. |
Token |
get()
Get a token from the mailbox receiver and specify a null Branch to control the execution of this method. |
Token |
get(Branch branch)
Return a token from the queue. |
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(Branch branch)
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 true if this receiver is read blocked; return false otherwise. |
boolean |
isWriteBlocked()
Return true if this receiver is write blocked; return false otherwise. |
void |
prepareToBlock(Branch branch)
Prepare to register a block. |
void |
put(Token token)
Do a blocking write on the queue. |
void |
put(Token token,
Branch branch)
Do a blocking write on the queue. |
void |
put(Token token,
double time)
Do a blocking write on the queue. |
void |
put(Token token,
double time,
Branch branch)
Do a blocking write on the queue. |
void |
requestFinish()
Schedule this receiver to terminate. |
void |
reset()
Reset local flags. |
void |
wakeUpBlockedPartner()
Unblock this receiver and register this new state with either the monitoring branch or the local director. |
| Methods inherited from class ptolemy.domains.dde.kernel.PrioritizedTimedQueue |
getCapacity, getLastTime, getReceiverTime, hasRoom, removeIgnoredToken, setCapacity |
| Methods inherited from class ptolemy.actor.AbstractReceiver |
getArray, getContainer, getCurrentTime, isKnown, putArray, setContainer |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface ptolemy.actor.Receiver |
getArray, getContainer, hasRoom, isKnown, putArray, setContainer |
| 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 Token get()
get in interface Receiverget in class PrioritizedTimedQueue
public Token get(Branch branch)
throws NoTokenException
IMPORTANT: This method is designed to be called after hasToken() has been called. Verify that this method is safe to call by calling hasToken() first. Note that this method does not perform a blocking read but hasToken() does.
get in interface ProcessReceiverNoTokenException - If this method is called while
hasToken() returns false.hasToken()public boolean hasRoom(int tokens)
hasRoom in interface ReceiverhasRoom in class PrioritizedTimedQueuetokens - 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 ReceiverhasToken in class PrioritizedTimedQueuepublic boolean hasToken(Branch branch)
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.
public boolean hasToken(int tokens)
hasToken in interface ReceiverhasToken in class PrioritizedTimedQueuetokens - The number of tokens to get from the queue.
public boolean isConsumerReceiver()
isConsumerReceiver in interface ProcessReceiverpublic boolean isConnectedToBoundary()
This method is not synchronized so the caller should be.
isConnectedToBoundary in interface ProcessReceiverBoundaryDetectorpublic boolean isConnectedToBoundaryInside()
This method is not synchronized so the caller should be.
isConnectedToBoundaryInside in interface ProcessReceiverBoundaryDetectorpublic boolean isConnectedToBoundaryOutside()
This method is not synchronized so the caller should be.
isConnectedToBoundaryOutside in interface ProcessReceiverBoundaryDetectorpublic boolean isProducerReceiver()
isProducerReceiver in interface ProcessReceiverpublic boolean isInsideBoundary()
This method is not synchronized so the caller should be.
isInsideBoundary in interface ProcessReceiverBoundaryDetectorpublic boolean isOutsideBoundary()
This method is not synchronized so the caller should be.
isOutsideBoundary in interface ProcessReceiverBoundaryDetectorpublic boolean isReadBlocked()
isReadBlocked in interface ProcessReceiverpublic boolean isWriteBlocked()
isWriteBlocked in interface ProcessReceiverpublic void prepareToBlock(Branch branch)
branch - The Branch managing execution of this method.public void clear()
clear in interface Receiverclear in class AbstractReceiverpublic void put(Token token)
put in interface Receiverput in class PrioritizedTimedQueuetoken - The token to put in the queue.
TerminateProcessException - If activity is scheduled
to cease.
public void put(Token token,
Branch branch)
If at any point during this method this receiver is scheduled for termination, then throw a TerminateProcessException which will cease activity for the actor that contains this receiver.
put in interface ProcessReceivertoken - The token to put in the queue.branch - The branch that monitors blocking write activity.
TerminateProcessException - If activity is scheduled
to cease.
public void put(Token token,
double time)
put in class PrioritizedTimedQueuetoken - The token to put in the queue.time - The specified time stamp.
TerminateProcessException - If activity is scheduled
to cease.
public void put(Token token,
double time,
Branch branch)
token - The token to put on the queue.time - The time stamp associated with the token.public void requestFinish()
requestFinish in interface ProcessReceiverpublic void reset()
reset in interface ProcessReceiverreset in class PrioritizedTimedQueuepublic void wakeUpBlockedPartner()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||