|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.actor.Director
ptolemy.actor.lib.hoc.ThreadedComposite.ThreadedDirector
private class ThreadedComposite.ThreadedDirector
A specialized director that fires a contained actor in a separate thread. The prefire() method returns true if the inside thread is alive. The fire() method posts input events, if any, for the current firing on a queue for the inside thread to consume. If the firing is in response to a prior refiring request by this director, then the fire() method will also wait for the inside thread to complete its firing, and will then produce outputs from that firing. The postfire() method posts a request to postfire the contained actor and also requests a refiring of this director at the current time plus the delay value (unless the delay value is UNDEFINED). The wrapup() method requests termination of the inside thread. If postfire() of the contained actor returns false, then postfire() of this director will return false, requesting a halt to execution of the model.
Nested Class Summary | |
---|---|
private class |
ThreadedComposite.ThreadedDirector.CompositeThread
The inside thread, which executes the contained actor. |
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private java.lang.Throwable |
_exception
If an exception occurs in the inside thread, the exception will be assigned to this member, which will cause the the next invocation of the fire() or wrapup() method to throw the exception. |
private java.util.Set<Time> |
_fireAtTimes
Record of the times which refire requests have been made and not yet processed by any of the fireAt() methods. |
private java.util.concurrent.LinkedBlockingQueue<ThreadedComposite.TokenFrame> |
_inputFrames
Queue of unprocessed input events. |
private java.util.List<ThreadedComposite.QueuedToken> |
_inputTokens
List of input events in the current iteration. |
private java.util.LinkedList<ThreadedComposite.TokenFrame> |
_outputFrames
Queue of unprocessed output events. |
private java.util.Queue<Time> |
_outputTimes
Record of the time stamps at which to produce outputs. |
private boolean |
_synchronizeToRealTime
The value of the synchronizeToRealTime parameter when initialize() was invoked. |
private java.lang.Thread |
_thread
The thread that executes the contained actors. |
Fields inherited from class ptolemy.actor.Director |
---|
_actorsFinishedExecution, _currentTime, _finishRequested, _initializables, _stopRequested, timeResolution |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Constructor Summary | |
---|---|
ThreadedComposite.ThreadedDirector(CompositeEntity container,
java.lang.String name)
Create a new instance of the director for ThreadedComposite. |
Method Summary | |
---|---|
java.lang.Object |
clone(Workspace workspace)
Clone the director into the specified workspace. |
void |
fire()
Produce outputs (if appropriate). |
Time |
fireAt(Actor actor,
Time time)
Delegate by calling fireAt() on the director of the container's container (the executive director), and make a local record that a refiring request has been made for the specified time. |
Time |
getModelTime()
Return the current time, which is the most recent input frame processed (or being processed) by the inside thread. |
void |
initialize()
Start the inside thread. |
Receiver |
newReceiver()
Return a new instance of QueueReceiver. |
boolean |
postfire()
Consume inputs (if any) and post a frame on the queue for the inside thread to consume. |
boolean |
prefire()
Return true if the inside thread is alive. |
void |
stop()
Override the base class to post a "stop frame" on the queue for the inside thread to stop. |
boolean |
transferInputs(IOPort port)
Record data from the specified input port for transfer to the queue used to communicate these data to the inside thread. |
boolean |
transferOutputs(IOPort port)
Override the base class to do nothing since the fire() method of this director directly handles producing the outputs. |
void |
wrapup()
Override the base class to wait until the inside thread terminates and then call super.wrapup(). |
Methods inherited from class ptolemy.kernel.util.Attribute |
---|
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.Throwable _exception
private java.util.Set<Time> _fireAtTimes
private java.util.concurrent.LinkedBlockingQueue<ThreadedComposite.TokenFrame> _inputFrames
private java.util.List<ThreadedComposite.QueuedToken> _inputTokens
private java.util.LinkedList<ThreadedComposite.TokenFrame> _outputFrames
private java.util.Queue<Time> _outputTimes
private boolean _synchronizeToRealTime
private java.lang.Thread _thread
Constructor Detail |
---|
public ThreadedComposite.ThreadedDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container for the director.name
- The name of the director.
IllegalActionException
- Not thrown in this base class.
NameDuplicationException
- Not thrown in this base class.Method Detail |
---|
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Attribute
workspace
- The workspace for the new object.
java.lang.CloneNotSupportedException
- If a derived class has
has an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class Director
IllegalActionException
- If production of an output
fails (e.g. type error), or if this thread is interrupted
while we are waiting for output to produce.public Time fireAt(Actor actor, Time time) throws IllegalActionException
fireAt
in class Director
actor
- The actor requesting firing.time
- The time at which to fire.
IllegalActionException
- If the executive director throws it.Director.fireAtCurrentTime(Actor)
public Time getModelTime()
getModelTime
in class Director
Director.setModelTime(Time)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class Director
IllegalActionException
- If the initialize() method of
one of the inside actors throws it.public Receiver newReceiver()
newReceiver
in class Director
QueueReceiver
public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class Director
IllegalActionException
- Not thrown in this base class.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class Director
IllegalActionException
- Not thrown in this base class.public void stop()
stop
in interface Executable
stop
in class Director
public boolean transferInputs(IOPort port) throws IllegalActionException
transferInputs
in class Director
port
- The port to transfer tokens from.
IllegalActionException
- If reading the inputs fails.public boolean transferOutputs(IOPort port) throws IllegalActionException
transferOutputs
in class Director
port
- The port to transfer tokens from.
IllegalActionException
- If writing the outputs fails.public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class Director
IllegalActionException
- If the wrapup() method of
one of the associated actors throws it.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |