public class SyncOnTerminator extends TypedAtomicActor
Pass on a stream of tokens except for a specific element (termination) and
emit the termination when it is found in the stream
NumberOfOccurencesth times.
The input should be a stream of tokens of a given type that matches the type
of the terminator parameter of this actor.
Input tokens are passed on as long as the termination element is found as many times as specified. The termination element is not passed on until the NumberOfOccurencesth occurence. After the termination element is emitted, incoming tokens will raise an Exception.
This actor can be used in the following stream processing scenario. A stream, which has a termination token, is split and elements are processed in parallel and then merged non-deterministically again. In such a case, if the termination token is routed on only one branch, it can overcome other tokens at the merge. So the termination token should be routed on ALL branches and then after the merge this actor can help to wait for the last termination token and thus ensuring that the termination token is the very last token in the stream.
Note that for record types, you do not need to specify all fields within the terminator. E.g. if you have a stream with {name/string, value=int}, you can define the terminator, for instance, as {name="T"}.
If the flag discardOthers is set, the input tokens are NOT emitted on output. That is, there is only one output, the termination token on its NumberOfOccurencesth occurence.
The actor outputs the input tokens.
This actor is not always producing a token for an input (namely for the termination tokens), thus, it cannot be used in SDF. Since you do not have parallel stream processing under SDF, this can hardly be a problem.
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
Parameter |
discardOthers
A flag to indicate whether non-terminator tokens should be passed on or
discarded.
|
TypedIOPort |
input
Input token.
|
Parameter |
numberOfOccurences
The number of occurences of the terminator in the stream.
|
TypedIOPort |
output
The output token, which is always the input token.
|
Parameter |
terminator
The terminator element to wait for.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_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 |
---|
SyncOnTerminator(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(Attribute attribute)
Override the base class to determine which function is being specified.
|
void |
fire()
fire
|
void |
initialize()
initialize() runs once before first exec
|
java.util.List |
typeConstraintList()
Return the type constraints of this actor.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public TypedIOPort input
public Parameter terminator
public Parameter numberOfOccurences
public Parameter discardOthers
public TypedIOPort output
public SyncOnTerminator(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name of this actor.IllegalActionException
- If the actor cannot be contained by the proposed
container.NameDuplicationException
- If the container already has an actor with this name.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the parent class throws it.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the function is not recognized.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
public java.util.List typeConstraintList()
typeConstraintList
in class TypedAtomicActor
Inequality