ptolemy.domains.pn.kernel
Class NondeterministicMerge.MergeDirector

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.Director
              extended by ptolemy.actor.process.ProcessDirector
                  extended by ptolemy.actor.process.CompositeProcessDirector
                      extended by ptolemy.domains.pn.kernel.PNDirector
                          extended by ptolemy.domains.pn.kernel.NondeterministicMerge.MergeDirector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Executable, Initializable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Enclosing class:
NondeterministicMerge

private class NondeterministicMerge.MergeDirector
extends PNDirector

Variant of the PNDirector for the NondeterministicMerge actor.


Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.domains.pn.kernel.PNDirector
_readBlockedQueues, _writeBlockedQueues, initialQueueCapacity, maximumQueueCapacity, READ_BLOCKED, WRITE_BLOCKED
 
Fields inherited from class ptolemy.actor.process.ProcessDirector
_notDone, _stopFireRequested
 
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
NondeterministicMerge.MergeDirector(CompositeEntity container, java.lang.String name)
           
 
Method Summary
protected  boolean _resolveDeadlock()
          Attempt to resolve a deadlock and return true if the deadlock no longer exists and successive iterations are allowed; if the deadlock still exists then return false indicating that future iterations are not allowed.
 void addThread(java.lang.Thread thread)
          Override the base class to delegate to the executive director.
 void fire()
          Do nothing.
 boolean postfire()
          Return false since this director has nothing to do.
 void removeThread(java.lang.Thread thread)
          Override the base class to delegate to the executive director.
 void requestInitialization(Actor actor)
          Queue an initialization request with the manager.
 void threadBlocked(java.lang.Thread thread, ProcessReceiver receiver)
          Override the base class to delegate to the executive director.
 void threadBlocked(java.lang.Thread thread, ProcessReceiver receiver, boolean readOrWrite)
          Override the base class to delegate to the executive director.
 void threadHasPaused(java.lang.Thread thread)
          Override the base class to delegate to the executive director.
 void threadHasResumed(java.lang.Thread thread)
          Override the base class to delegate to the executive director.
 void threadUnblocked(java.lang.Thread thread, ProcessReceiver receiver)
          Override the base class to delegate to the executive director.
 void threadUnblocked(java.lang.Thread thread, ProcessReceiver receiver, boolean readOrWrite)
          Override the base class to delegate to the executive director.
 void wrapup()
          Do nothing.
 
Methods inherited from class ptolemy.domains.pn.kernel.PNDirector
_incrementLowestWriteCapacityPort, _resolveInternalDeadlock, addProcessListener, clone, initialize, newReceiver, preinitialize, removeProcessListener, suggestedModalModelDirectors, supportMultirateFiring
 
Methods inherited from class ptolemy.actor.process.CompositeProcessDirector
_areActorsExternallyBlocked, _areThreadsDeadlocked, _controllerBlocked, _controllerUnBlocked, _isInputControllerBlocked, _isOutputControllerBlocked, createBranchController, getInputController, getOutputController, prefire, setModelTime, stopInputBranchController, stopOutputBranchController
 
Methods inherited from class ptolemy.actor.process.ProcessDirector
_areAllThreadsStopped, _getActiveThreadsCount, _getBlockedThreadsCount, _getStoppedThreadsCount, _newProcessThread, finish, initialize, isStopFireRequested, isStopRequested, isThreadActive, stop, stopFire, terminate, transferInputs, transferOutputs
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, fireAt, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getErrorTolerance, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, invalidateResolvedTypes, invalidateSchedule, isFireFunctional, isStrict, iterate, preinitialize, removeInitializable, setContainer, setCurrentTime
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NondeterministicMerge.MergeDirector

public NondeterministicMerge.MergeDirector(CompositeEntity container,
                                           java.lang.String name)
                                    throws IllegalActionException,
                                           NameDuplicationException
Throws:
IllegalActionException
NameDuplicationException
Method Detail

requestInitialization

public void requestInitialization(Actor actor)
Queue an initialization request with the manager. The specified actor will be initialized at an appropriate time, between iterations, by calling its preinitialize() and initialize() methods. This method is called by CompositeActor when an actor sets its container to that composite actor. Typically, that will occur when a model is first constructed, and during the execute() method of a ChangeRequest. We do nothing here in this implementation: When these actors are added during the initialization phase setContainer results in the call of this method, which will requestInitialization, which will normally delegate the action to the Manager. super.initialize() in NondeterministicMerge will however initialize the director of this composite actor (the MergeDirector), which will initialize the newly created actors. Hence we don't need to do it again here.

Overrides:
requestInitialization in class Director
Parameters:
actor - The actor to initialize.

addThread

public void addThread(java.lang.Thread thread)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
addThread in class ProcessDirector
Parameters:
thread - The thread.
See Also:
ProcessDirector.removeThread(Thread)

fire

public void fire()
Do nothing.

Specified by:
fire in interface Executable
Overrides:
fire in class ProcessDirector

postfire

public boolean postfire()
Return false since this director has nothing to do.

Specified by:
postfire in interface Executable
Overrides:
postfire in class PNDirector
Returns:
False.

removeThread

public void removeThread(java.lang.Thread thread)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
removeThread in class ProcessDirector
Parameters:
thread - The thread.
See Also:
ProcessDirector.addThread(Thread)

threadBlocked

public void threadBlocked(java.lang.Thread thread,
                          ProcessReceiver receiver)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
threadBlocked in class CompositeProcessDirector
Parameters:
thread - The thread.
receiver - The receiver handling the I/O operation, or null if it is not a specific receiver.
See Also:
threadBlocked(Thread, ProcessReceiver, boolean)

threadBlocked

public void threadBlocked(java.lang.Thread thread,
                          ProcessReceiver receiver,
                          boolean readOrWrite)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
threadBlocked in class PNDirector
Parameters:
thread - The thread.
receiver - The receiver handling the I/O operation, or null if it is not a specific receiver.
readOrWrite - Either READ_BLOCKED or WRITE_BLOCKED to indicate whether the thread is blocked on read or write.
See Also:
threadBlocked(Thread, ProcessReceiver)

threadHasPaused

public void threadHasPaused(java.lang.Thread thread)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
threadHasPaused in class ProcessDirector
Parameters:
thread - The thread.
See Also:
ProcessDirector.addThread(Thread)

threadHasResumed

public void threadHasResumed(java.lang.Thread thread)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
threadHasResumed in class ProcessDirector
Parameters:
thread - The thread.
See Also:
ProcessDirector.threadHasPaused(Thread)

threadUnblocked

public void threadUnblocked(java.lang.Thread thread,
                            ProcessReceiver receiver)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
threadUnblocked in class CompositeProcessDirector
Parameters:
thread - The thread.
receiver - The receiver handling the I/O operation, or null if it is not a specific receiver.
See Also:
threadBlocked(Thread, ProcessReceiver)

threadUnblocked

public void threadUnblocked(java.lang.Thread thread,
                            ProcessReceiver receiver,
                            boolean readOrWrite)
Override the base class to delegate to the executive director. This director does not keep track of threads.

Overrides:
threadUnblocked in class PNDirector
Parameters:
thread - The thread.
receiver - The receiver handling the I/O operation, or null if it is not a specific receiver.
readOrWrite - Either READ_BLOCKED or WRITE_BLOCKED to indicate whether the thread is blocked on read or write.
See Also:
threadBlocked(Thread, ProcessReceiver, boolean)

wrapup

public void wrapup()
Do nothing.

Specified by:
wrapup in interface Initializable
Overrides:
wrapup in class CompositeProcessDirector

_resolveDeadlock

protected boolean _resolveDeadlock()
Description copied from class: CompositeProcessDirector
Attempt to resolve a deadlock and return true if the deadlock no longer exists and successive iterations are allowed; if the deadlock still exists then return false indicating that future iterations are not allowed. If the deadlock is internal then apply a domain specific algorithm to attempt deadlock resolution via the _resolveInternalDeadlock() method. If the algorithm is successful and deadlock no longer exists then return true. If the algorithm is unsuccessful and deadlock persists then end the iteration and return false.

If the deadlock is an external deadlock and the containing model of computation is process-oriented, then register the externally blocked receivers with the composite actor that contains this director's composite actor. If the deadlock is an external deadlock and the containing model of computation is schedule-oriented, then end this iteration and return true.

While in special cases it my be useful to override this method for domain specific functionality it is more likely that this method will remain the same and the _resolveInternalDeadlock() method will be overridden for particular models of computation.

Overrides:
_resolveDeadlock in class CompositeProcessDirector
Returns:
false If deadlock could not be resolved and successive iterations are not allowed; return true otherwise.