
ResourcePool |
ptolemy.domains.rendezvous.lib.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 <i>grant</i> output port and released on the
<i>release</i> input port. These ports are both multiports,
so resources can be granted to multiple users of the resources,
and released by multiple actors.
<p>
The initial pool of resources is provided by the <i>initialPool</i>
parameter, which is an array of arbitrary type. The <i>grant</i>
output port and <i>release</i> input port are constrained to have
compatible types. Specifically, the <i>grant</i> 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 <i>release</i> input.
<p>
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 <i>release</i>
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 <i>grant</i>
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.
<p>
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.
Author(s): Edward A. Lee
Version:$Id: ResourcePool.doc.html,v 1.1 2006/02/22 18:41:22 mangal Exp $
Pt.Proposed Rating:Yellow (eal)
Pt.Accepted Rating:Red (cxh)
grant
The output port through which this actor grants resources.
This port has type equal to the element type
of the <i>initialPool</i> parameter.
release
The input port through which other actors release resources.
This port has type equal to the element type
of the <i>initialPool</i> parameter.
initialPool
The initial resource pool. This is an array with default
value {1} (an integer array with one entry with value 1).