ptolemy.domains.dde.kernel
Class DDEThread

java.lang.Object
  extended by java.lang.Thread
      extended by ptolemy.kernel.util.PtolemyThread
          extended by ptolemy.actor.process.ProcessThread
              extended by ptolemy.domains.dde.kernel.DDEThread
All Implemented Interfaces:
java.lang.Runnable, Debuggable

public class DDEThread
extends ProcessThread

A DDEThread controls an actor according to DDE semantics. The primary purpose of a DDEThread is to control the iteration methods of an executing actor and to maintain the actor's local notion of time according to DDE semantics. A DDEThread has two unique functionalities for accomplishing this goal. First a DDEThread instantiates a TimeKeeper object. A TimeKeeper manages a given actor's local notion of time according to DDE semantics. The second task of a DDEThread is to notify directly connected actors when the actor controlled by the thread is ending execution.

Since:
Ptolemy II 0.3
Version:
$Id: DDEThread.java 57040 2010-01-27 20:52:32Z cxh $
Author:
John S. Davis II
See Also:
TimeKeeper
Accepted Rating:
Yellow (yuhong)
Proposed Rating:
Yellow (davisj)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  TimeKeeper _timeKeeper
           
 
Fields inherited from class ptolemy.kernel.util.PtolemyThread
_debugging, _debugListeners
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DDEThread(Actor actor, ProcessDirector director)
          Construct a thread to be used to execute the iteration methods of a DDEActor.
 
Method Summary
 TimeKeeper getTimeKeeper()
          Return the time keeper that keeps time for the actor that this thread controls.
 void noticeOfTermination()
          Notify output-connected actors that the actor controlled by this thread is ending execution.
 void start()
          Start this thread and initialize the time keeper to a future time if specified in the director's initial time table.
 void wrapup()
          End the execution of the actor under the control of this thread.
 
Methods inherited from class ptolemy.actor.process.ProcessThread
getActor, run
 
Methods inherited from class ptolemy.kernel.util.PtolemyThread
_debug, _debug, addDebugListener, removeDebugListener
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_timeKeeper

private TimeKeeper _timeKeeper
Constructor Detail

DDEThread

public DDEThread(Actor actor,
                 ProcessDirector director)
          throws IllegalActionException
Construct a thread to be used to execute the iteration methods of a DDEActor. This increases the count of active actors in the director.

Parameters:
actor - The DDEActor that will be executed.
director - The director of this actor.
Throws:
IllegalActionException - If thrown while create a new TimeKeeper.
Method Detail

getTimeKeeper

public TimeKeeper getTimeKeeper()
Return the time keeper that keeps time for the actor that this thread controls.

Returns:
The TimeKeeper of the actor that this thread controls.

noticeOfTermination

public void noticeOfTermination()
Notify output-connected actors that the actor controlled by this thread is ending execution. Output-connected actors are those that are connected to the actor controlled by this thread via output ports of this thread's actor. Send events with time stamps of PrioritizedTimedQueue.INACTIVE to these "downstream" actors.

See Also:
PrioritizedTimedQueue

start

public void start()
Start this thread and initialize the time keeper to a future time if specified in the director's initial time table. Use this method to facilitate any calls to DDEDirector.fireAt() that occur prior to the creation of this thread. If fireAt() was called for time 'T' with respect to the actor that this thread controls, then set the current time of this threads TimeKeeper to time 'T.'

NOTE: This method assumes an implementation of fireAt() that would be more appropriately named continueAt().

Overrides:
start in class java.lang.Thread

wrapup

public void wrapup()
            throws IllegalActionException
End the execution of the actor under the control of this thread. Notify all actors connected to this actor that this actor is preparing to cease execution.

Overrides:
wrapup in class ProcessThread
Throws:
IllegalActionException - If an error occurs while ending execution of the actor under the control of this thread.