|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.actor.AbstractReceiver
ptolemy.domains.csp.kernel.CSPReceiver
Receiver for CSP style communication. In CSP all communication is via synchronous message passing, so both the the sending and receiving process need to rendezvous at the receiver. For rendezvous, the receiver is the key synchronization point. It is assumed each receiver has at most one thread trying to send to it and at most one thread trying to receive from it at any one time. The receiver performs the synchronization necessary for simple rendezvous (get() and put() operations). It also stores the flags that allow the ConditionalSend and ConditionalReceive branches to know when they can proceed.
| Green (kienhuis) |
| Green (nsmyth) |
| Constructor Summary | |
CSPReceiver()
Construct a CSPReceiver with no container. |
|
CSPReceiver(IOPort container)
Construct a CSPReceiver with the specified container. |
|
| Method Summary | |
protected void |
_checkFlagsAndWait()
This method wraps the wait() call between checks on the state of the receiver. |
protected ConditionalBranchController |
_getOtherController()
The controller of the conditional branch to reach the rendezvous point first. |
protected boolean |
_isConditionalReceiveWaiting()
Flag indicating whether or not a ConditionalReceive is trying to rendezvous with this receiver. |
protected boolean |
_isConditionalSendWaiting()
Flag indicating whether or not a ConditionalSend is trying to rendezvous with this receiver. |
protected boolean |
_isGetWaiting()
Flag indicating whether or not a get() is waiting to rendezvous at this receiver. |
protected boolean |
_isPutWaiting()
Flag indicating whether or not a put() is waiting to rendezvous at this receiver. |
protected void |
_setConditionalReceive(boolean v,
ConditionalBranchController p,
int otherID)
Set a flag so that a ConditionalSend branch knows whether or not a ConditionalReceive is ready to rendezvous with it. |
protected void |
_setConditionalSend(boolean v,
ConditionalBranchController p,
int otherID)
Set a flag so that a ConditionalReceive branch knows whether or not a ConditionalSend is ready to rendezvous with it. |
void |
clear()
Reset local flags. |
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)
Retrieve a Token from the receiver by rendezvous. |
protected int |
getOtherID()
|
boolean |
hasRoom()
Return true. |
boolean |
hasRoom(int tokens)
Return true. |
boolean |
hasToken()
Return true. |
boolean |
hasToken(int tokens)
Return true. |
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 |
markBlocked(Branch branch)
If this receiver is involved in a branch, then mark the receiver blocked; otherwise mark the actor blocked. |
void |
markUnblocked()
If this receiver is involved in a branch, then mark the receiver unblocked; otherwise mark the actor unblocked. |
void |
put(Token token)
Put a token into the mailbox receiver and specify a null Branch to control the execution of this method. |
void |
put(Token t,
Branch branch)
Place a Token into the receiver via rendezvous. |
void |
requestFinish()
The model has finished executing, so set a flag so that the next time an actor tries to get or put it gets a TerminateProcessException which will cause it to finish. |
void |
reset()
Reset local flags. |
| 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, isKnown, putArray, setContainer |
| Constructor Detail |
public CSPReceiver()
public CSPReceiver(IOPort container)
throws IllegalActionException
container - The port containing this receiver.
IllegalActionException - If this receiver cannot be
contained by the proposed container.| Method Detail |
public void clear()
clear in interface Receiverclear in class AbstractReceiverpublic Token get()
get in interface Receiverget in class AbstractReceiverpublic Token get(Branch branch)
get in interface ProcessReceiverTerminateProcessException - If execution termination
has been requested, or if the execution is abruptly terminated
from the outside (via an InterruptedException).public boolean hasRoom()
hasRoom in interface ReceiverhasRoom in class AbstractReceiverpublic boolean hasRoom(int tokens)
hasRoom in interface ReceiverhasRoom in class AbstractReceivertokens - The number of tokens to put into this receiver.
public boolean hasToken()
hasToken in interface ReceiverhasToken in class AbstractReceiverpublic boolean hasToken(int tokens)
hasToken in interface ReceiverhasToken in class AbstractReceivertokens - The number of tokens desired.
public boolean isConnectedToBoundary()
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()
isInsideBoundary in interface ProcessReceiverBoundaryDetectorpublic boolean isOutsideBoundary()
isOutsideBoundary in interface ProcessReceiverBoundaryDetectorpublic boolean isProducerReceiver()
isProducerReceiver in interface ProcessReceiverpublic boolean isReadBlocked()
isReadBlocked in interface ProcessReceiverpublic boolean isWriteBlocked()
isWriteBlocked in interface ProcessReceiverpublic void markBlocked(Branch branch)
public void markUnblocked()
public void put(Token token)
put in interface Receiverput in class AbstractReceivertoken - The token to put into the receiver.
public void put(Token t,
Branch branch)
put in interface ProcessReceivert - The token being transferred in the rendezvous.
TerminateProcessException - If execution termination
has been requested, or if the execution is abruptly terminated
from the outside (via an InterruptedException).public void requestFinish()
requestFinish in interface ProcessReceiverpublic void reset()
reset in interface ProcessReceiver
protected void _checkFlagsAndWait()
throws TerminateProcessException,
java.lang.InterruptedException
TerminateProcessException - If the actor to
which this receiver belongs has been terminated while still
running i.e it was not allowed to run to completion.
java.lang.InterruptedException - If the actor is
interrupted while waiting(for a rendezvous to complete).protected ConditionalBranchController _getOtherController()
protected int getOtherID()
protected boolean _isConditionalReceiveWaiting()
protected boolean _isConditionalSendWaiting()
protected boolean _isGetWaiting()
protected boolean _isPutWaiting()
protected void _setConditionalSend(boolean v,
ConditionalBranchController p,
int otherID)
v - Boolean indicating whether or not a conditional
send is waiting to rendezvous.p - The CSPActor which contains the ConditionalSend
branch that is trying to rendezvous. It is stored in the
receiver so that if a ConditionalReceive arrives, it can easily
check whether the ConditionalSend branch was the first
branch of its conditional construct(CIF or CDO) to succeed.otherID - The branch ID of the branch requesting the
conditional send.
protected void _setConditionalReceive(boolean v,
ConditionalBranchController p,
int otherID)
v - Boolean indicating whether or not a conditional
receive is waiting to rendezvous.p - The CSPActor which contains the ConditionalReceive
branch that is trying to rendezvous. It is stored in the
receiver so that if a ConditionalSend arrives, it can easily
check whether the ConditionalReceive branch was the first
branch of its conditional construct(CIF or CDO) to succeed.otherID - The branch ID of the branch requesting the
conditional receive.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||