|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.actor.Director
ptolemy.actor.process.ProcessDirector
The base class for directors for the process oriented domains. It provides default implementations for methods that are common across such domains.
In the process oriented domains, the director controlling a model needs to keep track of the state of the model. In particular it needs to maintain an accurate count of the number of active processes under its control and any processes that are blocked for whatever reason (trying to read from an empty channel as in PN). These counts, and perhaps other counts, are needed by the director to control and respond when deadlock is detected (no processes can make progress), or to respond to requests from higher in the hierarchy.
The methods that control how the director detects and responds to deadlocks are _areActorsDeadlocked() and _resolveDeadlock(). These methods should be overridden in derived classes to get domain-specific behaviour. The implementations given here are trivial and suffice only to illustrate the approach that should be followed.
This base class is not sufficient for executing hierarchical, heterogeneous models. In order to accommodate hierarchical, heterogeneity the subclass CompositeProcessDirector must be used.
Director,
Serialized Form
| Yellow (mudit) |
| Green (mudit) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.util.NamedObj |
NamedObj.ContainedObjectsIterator |
| Field Summary | |
protected boolean |
_notDone
|
| Fields inherited from class ptolemy.actor.Director |
_currentTime, _stopRequested |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Fields inherited from interface ptolemy.actor.Executable |
COMPLETED, NOT_READY, STOP_ITERATING |
| Constructor Summary | |
ProcessDirector()
Construct a director in the default workspace with an empty string as its name. |
|
ProcessDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name. |
|
ProcessDirector(Workspace workspace)
Construct a director in the workspace with an empty name. |
|
| Method Summary | |
protected void |
_actorBlocked(java.util.LinkedList receivers)
Increase the count of blocked actors by one and register the receivers that instigated the newly blocked actor. |
protected void |
_actorBlocked(ProcessReceiver receiver)
Increase the count of blocked actors by one and register the receiver that instigated the newly blocked actor. |
protected void |
_actorHasRestarted()
Decrease the count of stopped actors by one. |
protected void |
_actorHasStopped()
Increase the count of stopped actors by one. |
protected void |
_actorUnBlocked(java.util.LinkedList receivers)
Decrease the count of blocked actors by one and unregister the receivers that were previously blocked. |
protected void |
_actorUnBlocked(ProcessReceiver receiver)
Decrease the count of blocked actors by one and unregister the receiver that was previously blocked. |
protected void |
_addNewThread(ProcessThread thread)
Add a thread to the list of threads in the model. |
protected boolean |
_areActorsDeadlocked()
Return true if the count of active processes in the container is 0. |
protected boolean |
_areAllActorsStopped()
Return true if the count of active processes equals the number of stopped threads. |
protected void |
_decreaseActiveCount()
Decrease by one the count of active processes under the control of this director. |
protected long |
_getActiveActorsCount()
Return the number of active processes under the control of this director. |
protected int |
_getBlockedActorsCount()
Return the number of actors that are currently blocked. |
protected ProcessThread |
_getProcessThread(Actor actor,
ProcessDirector director)
Create a new ProcessThread for controlling the actor that is passed as a parameter of this method. |
protected int |
_getStoppedActorsCount()
Return the number of actors that are currently stopped. |
protected void |
_increaseActiveCount()
Increases the count of active actors in the composite actor corresponding to this director by 1. |
protected boolean |
_resolveDeadlock()
Return false indicating that deadlock has not been resolved and that execution will be discontinued. |
java.lang.Object |
clone(Workspace workspace)
Clone the director into the specified workspace. |
void |
fire()
Wait until a deadlock is detected. |
void |
initialize()
Invoke the initialize() methods of all the deeply contained actors in the container (a composite actor) of this director. |
void |
initialize(Actor actor)
Initialize the given actor. |
boolean |
isStopFireRequested()
Return true if a stop has been requested on the director. |
boolean |
isStopRequested()
Return true if a stop has been requested on the director. |
Receiver |
newReceiver()
Return a new receiver of a type compatible with this director. |
boolean |
postfire()
Return false if a stop has been requested or if the model has reached deadlock. |
boolean |
prefire()
Start threads for all actors that have not had threads started already (this might include actors initialized since the last invocation of prefire). |
void |
preinitialize()
Preinitialize the model controlled by this director. |
void |
stop()
Request that the director cease execution altogether. |
void |
stopFire()
Request that execution stop at the conclusion of the current iteration. |
void |
terminate()
Terminates all threads under control of this director immediately. |
boolean |
transferInputs(IOPort port)
Throw an IllegalActionException as an indication that this method should not be used within process domains. |
boolean |
transferOutputs(IOPort port)
Throw an IllegalActionException as an indication that this method should not be used within process domains. |
void |
wrapup()
End the execution of the model under the control of this director. |
| Methods inherited from class ptolemy.kernel.util.Attribute |
_getContainedObject, _propagateExistence, getContainer, setName |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected boolean _notDone
| Constructor Detail |
public ProcessDirector()
public ProcessDirector(Workspace workspace)
workspace - The workspace of this object.
public ProcessDirector(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
container - The containername - Name of this director.
IllegalActionException - If the name contains a period,
or if the director is not compatible with the specified container.
NameDuplicationException - If the container not a
CompositeActor and the name collides with an entity in the container.| Method Detail |
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
clone in class Attributeworkspace - The workspace for the cloned object.
java.lang.CloneNotSupportedException - If one of the attributes
cannot be cloned.
public void fire()
throws IllegalActionException
fire in interface Executablefire in class DirectorIllegalActionException - If a derived class throws it.
public void initialize()
throws IllegalActionException
initialize in interface Executableinitialize in class DirectorIllegalActionException - If the initialize() method
of one of the deeply contained actors throws it.
public void initialize(Actor actor)
throws IllegalActionException
initialize in class DirectorIllegalActionException - If the actor is not
acceptable to the domain. Not thrown in this base class.public boolean isStopRequested()
public boolean isStopFireRequested()
public Receiver newReceiver()
newReceiver in class Director
public boolean postfire()
throws IllegalActionException
postfire in interface Executablepostfire in class DirectorIllegalActionException - If a derived class throws it.
public boolean prefire()
throws IllegalActionException
prefire in interface Executableprefire in class DirectorIllegalActionException - If a derived class throws it.
public void preinitialize()
throws IllegalActionException
preinitialize in interface Executablepreinitialize in class DirectorIllegalActionException - If creating an actor thread
throws it.public void stop()
stop in interface Executablestop in class Directorpublic void stopFire()
stopFire in interface ExecutablestopFire in class Directorpublic void terminate()
terminate in interface Executableterminate in class Director
public boolean transferInputs(IOPort port)
throws IllegalActionException
transferInputs in class Directorport - The port to transfer tokens from.
IllegalActionException - Always thrown. This method
should not be invoked within the process domains.IOPort.transferInputs()
public boolean transferOutputs(IOPort port)
throws IllegalActionException
transferOutputs in class Directorport - The port to transfer tokens from.
IllegalActionException - Always thrown. This method
should not be invoked within the process domains.IOPort.transferOutputs()
public void wrapup()
throws IllegalActionException
This method is not synchronized on the workspace, so the caller should be.
wrapup in interface Executablewrapup in class DirectorIllegalActionException - If an error occurs while
accessing the receivers of all actors under the control of
this director.protected void _actorBlocked(ProcessReceiver receiver)
receiver - The receiver whose data transfer is blocked.protected void _actorBlocked(java.util.LinkedList receivers)
receivers - The receivers whose data transfer is blocked.protected void _actorHasStopped()
protected void _actorHasRestarted()
protected void _actorUnBlocked(ProcessReceiver receiver)
receiver - The receiver whose data transfer was
previously blocked.protected void _actorUnBlocked(java.util.LinkedList receivers)
receivers - The receivers whose data transfer was
previously blocked.protected void _addNewThread(ProcessThread thread)
thread - The newly created thread.protected boolean _areActorsDeadlocked()
protected boolean _areAllActorsStopped()
protected void _decreaseActiveCount()
protected final long _getActiveActorsCount()
protected final int _getBlockedActorsCount()
protected final int _getStoppedActorsCount()
protected ProcessThread _getProcessThread(Actor actor,
ProcessDirector director)
throws IllegalActionException
actor - The actor that the created ProcessThread will
control.director - The director that manages the model that the
created thread is associated with.
IllegalActionExceptionprotected void _increaseActiveCount()
protected boolean _resolveDeadlock()
throws IllegalActionException
IllegalActionException - Not thrown in this base class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||