|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.actor.AbstractReceiver
ptolemy.actor.QueueReceiver
ptolemy.domains.pn.kernel.PNQueueReceiver
A receiver with a FIFO queue that blocks the calling process on a read if the FIFO queue is empty and on a write if the queue is full. Blocking read provides the basic functionality of a FIFO channel in the process networks model of computation. Blocking write supports the implementation suggested by Parks for bounded memory execution of process networks.
Tokens are appended to the queue with the put() method, which blocks on a write if the queue is full. Tokens are removed from the queue with the get() method, which blocks on a read if the queue is empty. In case a process blocks on a read or a write, the receiver informs the director about the same. The receiver also unblocks processes blocked on a read or a write. In case a process is blocked on a read (read-blocked), it is unblocked on availability of a token. If a process is blocked on a write (write-blocked), it is unblocked on the availability of room in the queue and informs the director of the same.
This class is also responsible for pausing or terminating a process that tries to read from or write to the receiver. In case of termination, the receiver throws a TerminateProcessException when a process tries to read from or write to the receiver. This terminates the process. In case of pausing, the receiver suspends the process when it tries to read from or write to the receiver and resumes it only after a request to resume the process has been received.
QueueReceiver,
QueueReceiver
| Green (davisj) |
| Green (mudit) |
| Field Summary |
| Fields inherited from class ptolemy.actor.QueueReceiver |
_queue, INFINITE_CAPACITY |
| Constructor Summary | |
PNQueueReceiver()
Construct an empty receiver with no container |
|
PNQueueReceiver(IOPort container)
Construct an empty receiver with the specified container. |
|
| Method Summary | |
Token |
get()
Get a token from this receiver. |
Token |
get(Branch branch)
Remove and return the oldest token from the FIFO queue contained in the receiver. |
boolean |
hasRoom()
Return true, since a channel in the Kahn process networks model of computation is of infinite capacity and always has room. |
boolean |
hasRoom(int tokens)
Return true, since a channel in the Kahn process networks model of computation is of infinite capacity and always has room. |
boolean |
hasToken()
Return true, since a call to the get() method of the receiver will always return a token if the call to get() ever returns. |
boolean |
hasToken(int tokens)
Return true, since a call to the get() method of the receiver will always return a token if the call to get() ever returns. |
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()
This class serves as an example of a ConsumerReceiver and hence this method returns true; |
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()
This class serves as an example of a ProducerReceiver and hence this method returns true; |
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 |
prepareToBlock(Branch branch)
Prepare to register a block. |
void |
put(Token token)
Put a token on the queue contained in this receiver. |
void |
put(Token token,
Branch branch)
Put a token on the queue contained in this receiver. |
void |
requestFinish()
Set a flag in the receiver to indicate the onset of termination. |
void |
reset()
Reset the state variables in the receiver. |
void |
setReadPending(boolean readPending)
Set a state flag indicating that there is a process blocked while trying to read from this receiver. |
void |
setWritePending(boolean writePending)
Set a state flag indicating that there is a process blocked (write-blocked) while trying to write to the receiver. |
void |
wakeUpBlockedPartner()
Unblock this receiver and register this new state with either the monitoring branch or the local director. |
| Methods inherited from class ptolemy.actor.QueueReceiver |
clear, elementList, elements, get, getCapacity, getHistoryCapacity, historyElementList, historyElements, historySize, setCapacity, setHistoryCapacity, size |
| 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 |
clear, getArray, getContainer, isKnown, putArray, setContainer |
| Constructor Detail |
public PNQueueReceiver()
public PNQueueReceiver(IOPort container)
throws IllegalActionException
container - The container of this receiver.
IllegalActionException - If the container does
not accept this receiver.| Method Detail |
public void prepareToBlock(Branch branch)
branch - The Branch managing execution of this method.public void wakeUpBlockedPartner()
public Token get()
get in interface Receiverget in class QueueReceiverpublic Token get(Branch branch)
get in interface ProcessReceiverpublic boolean hasRoom()
hasRoom in interface ReceiverhasRoom in class QueueReceiverpublic boolean hasRoom(int tokens)
hasRoom in interface ReceiverhasRoom in class QueueReceivertokens - The number of tokens to put into the queue.
public boolean hasToken()
hasToken in interface ReceiverhasToken in class QueueReceiverpublic boolean hasToken(int tokens)
hasToken in interface ReceiverhasToken in class QueueReceivertokens - The number of tokens to get from the queue.
public boolean isConnectedToBoundary()
This method is not synchronized so the caller
isConnectedToBoundary in interface ProcessReceiverBoundaryDetectorpublic boolean isConnectedToBoundaryInside()
This method is not synchronized so the caller
isConnectedToBoundaryInside in interface ProcessReceiverBoundaryDetectorpublic boolean isConnectedToBoundaryOutside()
This method is not synchronized so the caller
isConnectedToBoundaryOutside in interface ProcessReceiverBoundaryDetectorpublic boolean isConsumerReceiver()
isConsumerReceiver 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 isProducerReceiver()
isProducerReceiver in interface ProcessReceiverpublic boolean isReadBlocked()
isReadBlocked in interface ProcessReceiverpublic boolean isWriteBlocked()
isWriteBlocked in interface ProcessReceiverpublic void put(Token token)
put in interface Receiverput in class QueueReceivertoken - The token to be put in the receiver.
public void put(Token token,
Branch branch)
put in interface ProcessReceivertoken - The token to be put in the receiver.public void reset()
reset in interface ProcessReceiverpublic void setReadPending(boolean readPending)
readPending - true if the calling process is blocking on a
read, false otherwise.public void setWritePending(boolean writePending)
writePending - true if the calling process is blocking on
a write, false otherwise.public void requestFinish()
requestFinish in interface ProcessReceiver
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||