|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ProcessReceiver
A ProcessReceiver is an interface for receivers in the process oriented domains. It adds methods to the Receiver interface for setting flags that indicate whether a termination of the simulation has been requested. In addition, methods are available to accommodate hierarchical heterogeneity via composite actors.
In process oriented domains, simulations are normally ended on the
detection of a deadlock. During a deadlock, processes or the
corresponding threads are normally waiting on a call to some
methods (for reading or writing) on a receiver.
To terminate or end the simulation, these methods should
either return or throw an exception to inform the processes that they
should terminate themselves. For this a method requestFinish() is defined.
This method would set a local flag in the receivers and wake up all the
processes waiting on some call to the receiver. On waking up these
processes would see that the termination flag set and behave accordingly.
A sample implementation is
public synchronized void requestFinish() {
_terminate = true;
notifyAll();
}
To accommodate hierarchical heterogeneity, an instantiation of ProcessReceiver must be able to determine its topological location with respect to boundary ports. A boundary port is an opaque port that is contained by a composite actor. This ability is enforced with the isConnectedToBoundary(), isConnectedToBoundaryOutside(), isConnectedToBoundaryInside(), isInsideBoundary() and isOutsideBoundary() methods. For convenience, the BoundaryDetector class is available to to simplify the implementation of these methods.
Blocking reads and writes are accommodated via the get(Branch) and put(Token, Branch) methods. In cases where a branch attempts to get data from or put data into a process receiver, it calls, respectively, these methods by passing itself as an argument. The process receiver then knows to register any blocks with the branch rather than with a director as is occurs in non-composite cases.
Note that it is not necessary for an implementation of ProcessReceiver to be used in the ports of an opaque composite actor. It is perfectly fine for a ProcessReceiver implementation to be used in the ports of an atomic actor. In such cases the get() and put() methods are called without the use of a branch object. If blocking reads or writes occur they are registered with the controlling director without the need for a branch or branch controller.
BoundaryDetector
Yellow (mudit) |
Green (mudit) |
Method Summary | |
---|---|
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()
Determine whether this receiver is read blocked. |
boolean |
isWriteBlocked()
Determine whether this receiver is write blocked. |
void |
requestFinish()
Set a local flag requesting that the simulation be finished. |
void |
reset()
Reset the local flags of this receiver. |
Methods inherited from interface ptolemy.actor.Receiver |
---|
clear, elementList, get, getArray, getContainer, hasRoom, hasRoom, hasToken, hasToken, isKnown, put, putArray, putArrayToAll, putToAll, setContainer |
Method Detail |
---|
boolean isConnectedToBoundary() throws IllegalActionException
It is suggested that this method be implemented using the BoundaryDetector class although such an implementation is not necessary.
IllegalActionException
BoundaryDetector
boolean isConnectedToBoundaryInside() throws InvalidStateException, IllegalActionException
It is suggested that this method be implemented using the BoundaryDetector class although such an implementation is not necessary.
IllegalActionException
InvalidStateException
BoundaryDetector
boolean isConnectedToBoundaryOutside() throws IllegalActionException
It is suggested that this method be implemented using the BoundaryDetector class although such an implementation is not necessary.
IllegalActionException
BoundaryDetector
boolean isConsumerReceiver() throws IllegalActionException
IllegalActionException
boolean isInsideBoundary()
It is suggested that this method be implemented using the BoundaryDetector class although such an implementation is not necessary.
BoundaryDetector
boolean isOutsideBoundary()
It is suggested that this method be implemented using the BoundaryDetector class although such an implementation is not necessary.
BoundaryDetector
boolean isProducerReceiver()
boolean isReadBlocked()
boolean isWriteBlocked()
void requestFinish()
void reset()
reset
in interface Receiver
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |