Readonly
capacityReadonly
capacityOptional
Readonly
freeReadonly
fullReadonly
logReadonly
resourcesReadonly
userReturns true if v
has an associted resource in the pool
Gets a pool item based on a 'user' key.
The same key should return the same pool item, for as long as it still exists.
If a 'user' already has a resource, it will 'keep alive' their use. If a 'user' does not already have resource
Resource pool It does the housekeeping of managing a limited set of resources which are shared by 'users'. All resources in the Pool are meant to be the same kind of object.
An example is an audio sketch driven by TensorFlow. We might want to allocate a sound oscillator per detected human body. A naive implementation would be to make an oscillator for each detected body. However, because poses appear/disappear unpredictably, it's a lot of extra work to maintain the binding between pose and oscillator.
Instead, we might use the Pool to allocate oscillators to poses. This will allow us to limit resources and clean up automatically if they haven't been used for a while.
Resources can be added manually with
addResource()
, or automatically by providing agenerate()
function in the Pool options. They can then be accessed via a user key. This is meant to associated with a single 'user' of a resource. For example, if we are associating oscillators with TensorFlow poses, the 'user key' might be the id of the pose.