public class MetroIIPNDirector extends PNDirector implements GetFirable
MetroIIPNDirector extends PNDirector and implements the MetroIIEventHandler interface. In addition to being blocked on read or write, the actors governed by MetroIIPNDirector may be blocked by MetroII events: 'Get.End' or 'Put.Begin'. 'Get.End' is PROPOSED after a token is successfully obtained from the receiver. And the actor is blocked until 'Get.End' is NOTIFIED. 'Put.Begin' is PROPOSED before trying to put a token into the receiver. Similarly, the actor is blocked until 'Put.Begin' is NOTIFIED.
Known issue: threads created by Yieldadapter correctly stop but the ones created by ProcessDirector do not. It seems stop() is called for each thread in ProcessDirector.stop() but no effect can be observed. Don't know why. BTW, stop() is a deprecated function in java.
The implementation is obsolete and needs to be updated.
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected java.util.Set |
_metroIIEventBlockedThreads
The set of threads that are blocked on an MetroII event.
|
_readBlockedQueues, _receivers, _writeBlockedQueues, initialQueueCapacity, maximumQueueCapacity, READ_BLOCKED, WRITE_BLOCKED
_newActorThreadList, _notDone
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
MetroIIPNDirector(CompositeEntity container,
java.lang.String name)
Constructs a director in the given container with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected int |
_getMetroIIEventBlockedThreadsCount()
Returns the number of threads that are currently blocked on a MetroII
event.
|
protected void |
_requestFinishOnReceivers()
Notifies all the threads blocked on MetroII events.
|
YieldAdapterIterable<java.lang.Iterable<metroIIcomm.Event.Builder>> |
adapter()
Returns the iterator for the caller function of getfire().
|
void |
addProposedMetroIIEvent(metroIIcomm.Event.Builder e)
Adds a proposed MetroII event into the director's event list.
|
java.lang.Object |
clone(Workspace workspace)
Clones the director into the specified workspace.
|
void |
getfire(ResultHandler<java.lang.Iterable<metroIIcomm.Event.Builder>> resultHandler)
Implements fire() with MetroII event handling.
|
Receiver |
newReceiver()
The same as super class except replacing the PNQueueReceiver by
MetroIIPNQueueReceiver.
|
void |
proposeMetroIIEvent(java.lang.String suffix)
Creates a MetroII event with the name: thread.getName()+suffix Add the
MetroII event into the director's event list.
|
_incrementLowestWriteCapacityPort, _resolveInternalDeadlock, addProcessListener, initialize, postfire, preinitialize, removeProcessListener, suggestedModalModelDirectors, supportMultirateFiring, threadBlocked, threadUnblocked
_areActorsExternallyBlocked, _areThreadsDeadlocked, _controllerBlocked, _controllerUnBlocked, _isInputControllerBlocked, _isOutputControllerBlocked, _resolveDeadlock, createBranchController, getInputController, getOutputController, prefire, stopInputBranchController, stopOutputBranchController, threadBlocked, threadUnblocked, wrapup
_areAllThreadsStopped, _getActiveThreadsCount, _getBlockedThreadsCount, _getStoppedThreadsCount, _newProcessThread, addThread, finish, fire, initialize, isStopFireRequested, isThreadActive, removeThread, stop, stopFire, terminate, threadHasPaused, threadHasResumed, transferInputs, transferOutputs
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, fireAt, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, suspend, transferOutputs
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, 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, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
protected java.util.Set _metroIIEventBlockedThreads
public MetroIIPNDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- Container of the director.name
- Name of this director.IllegalActionException
- If the director is not compatible with the specified
container. Thrown in derived classes.NameDuplicationException
- If the container not a CompositeActor and the name
collides with an entity in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class PNDirector
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be
cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public Receiver newReceiver()
newReceiver
in class PNDirector
public void addProposedMetroIIEvent(metroIIcomm.Event.Builder e)
e
- the event to be added.public YieldAdapterIterable<java.lang.Iterable<metroIIcomm.Event.Builder>> adapter()
adapter
in interface GetFirable
public void getfire(ResultHandler<java.lang.Iterable<metroIIcomm.Event.Builder>> resultHandler) throws CollectionAbortedException
getfire
in interface GetFirable
resultHandler
- iterable of events 'yield returned'.CollectionAbortedException
public void proposeMetroIIEvent(java.lang.String suffix) throws java.lang.InterruptedException
suffix
- The suffix of MetroII event namejava.lang.InterruptedException
protected final int _getMetroIIEventBlockedThreadsCount()
protected void _requestFinishOnReceivers()
_requestFinishOnReceivers
in class ProcessDirector