|
|||||||||
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.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.domains.rendezvous.lib.ResourcePool
public class ResourcePool
This actor manages a pool of resources, where each resource is represented by a token with an arbitrary value. Resources are granted on the grant output port and released on the release input port. These ports are both multiports, so resources can be granted to multiple users of the resources, and released by multiple actors.
The initial pool of resources is provided by the initialPool parameter, which is an array of arbitrary type. The grant output port and release input port are constrained to have compatible types. Specifically, the grant output port must be able to send tokens with types that match the elements of this array, and it must also be able to send tokens with types that match inputs provided at the release input.
This actor is designed for use in the rendezvous domain, where it will execute in its own thread. At all times, it is ready to rendezvous with any other actor connected to its release input port. When such a rendezvous occurs, the token provided at that input is added to the resource pool. In addition, whenever the resource pool is non-empty, this actor is ready to rendezvous with any actor connected to its grant output port. When such a rendezvous occurs, it sends the first token in the resource pool to that output port and removes that token from the resource pool.
The behavior of this actor is similar to that of the Merge actor, except that the Merge actor does no buffering. That is, while this actor is always ready to rendezvous with any input, the Merge actor is ready to rendezvous with an input only after it has delivered the previous input to the output.
Merge
,
Serialized Form
Red (cxh) |
Yellow (eal) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.Entity |
---|
Entity.ContainedObjectsIterator |
Field Summary | |
---|---|
private java.util.List |
_pool
The current resource pool. |
private boolean |
_postfireReturns
Flag indicating what postfire should return. |
private java.lang.Thread |
_readThread
The read thread, if it exists. |
TypedIOPort |
grant
The output port through which this actor grants resources. |
Parameter |
initialPool
The initial resource pool. |
TypedIOPort |
release
The input port through which other actors release resources. |
Fields inherited from class ptolemy.actor.AtomicActor |
---|
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested |
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 | |
---|---|
ResourcePool(CompositeEntity container,
java.lang.String name)
Construct an actor in the specified container with the specified name. |
Method Summary | |
---|---|
void |
attributeChanged(Attribute attribute)
Override the base class to reset the resource pool to match the specified initialPool value. |
java.lang.Object |
clone(Workspace workspace)
Override the base class to set the type constraints. |
void |
fire()
If the input width is greater than zero and it has not already been done, start a thread to read a token from the release input port and store it in the pool. |
void |
initialize()
Initialize. |
boolean |
postfire()
Return false if it is time to stop the process. |
Methods inherited from class ptolemy.actor.TypedAtomicActor |
---|
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints |
Methods inherited from class ptolemy.kernel.ComponentEntity |
---|
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
---|
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, preinitialize, removeInitializable, wrapup |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateValue |
Field Detail |
---|
public TypedIOPort grant
public TypedIOPort release
public Parameter initialPool
private java.util.List _pool
private boolean _postfireReturns
private java.lang.Thread _readThread
Constructor Detail |
---|
public ResourcePool(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name.
IllegalActionException
- If the actor cannot be contained
by the proposed container.
NameDuplicationException
- If the name coincides with
an actor already in the container.Method Detail |
---|
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.
IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class AtomicActor
workspace
- The workspace for the cloned object.
java.lang.CloneNotSupportedException
- If cloned ports cannot have
as their container the cloned entity (this should not occur), or
if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor
IllegalActionException
- If an error occurs during
executing the process.
TerminateProcessException
- If the process termination
is requested by the director.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor
IllegalActionException
- If a derived class throws it.public boolean postfire()
postfire
in interface Executable
postfire
in class AtomicActor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |