Vuo
1.2.0
|
A pool of shared objects — one object per key.
Each shared object is released immediately when its last user calls VuoRelease.
It's safe for multiple threads to call getSharedInstance() on the same pool.
Public Types | |
typedef InstanceType(* | AllocateFunctionType )(KeyType) |
A function that allocates InstanceType for a given key. | |
Public Member Functions | |
VuoKeyedPool (std::string instanceTypeString, AllocateFunctionType allocate) | |
See VUOKEYEDPOOL_DEFINE. | |
InstanceType | getSharedInstance (KeyType key) |
Returns a shared object for the specified key , allocating it if necessary. | |
void | removeSharedInstance (KeyType key) |
Removes key from the pool. | |
void | visit (void(^b)(KeyType, InstanceType)) |
Invokes block on each item in the pool. | |
unsigned int | size (void) |
Returns the number of items in the pool. | |
typedef InstanceType(* VuoKeyedPool< KeyType, InstanceType >::AllocateFunctionType)(KeyType) |
A function that allocates InstanceType
for a given key.
VuoKeyedPool< KeyType, InstanceType >::VuoKeyedPool | ( | std::string | instanceTypeString, |
AllocateFunctionType | allocate | ||
) |
See VUOKEYEDPOOL_DEFINE.
InstanceType VuoKeyedPool< KeyType, InstanceType >::getSharedInstance | ( | KeyType | key | ) |
Returns a shared object for the specified key
, allocating it if necessary.
This function may be called from any thread.
void VuoKeyedPool< KeyType, InstanceType >::removeSharedInstance | ( | KeyType | key | ) |
Removes key
from the pool.
This should only be called by objects' deallocate functions (as passed to VuoRegister
) prior to deinitializing and deallocating the object.
This function may be called from any thread.
unsigned int VuoKeyedPool< KeyType, InstanceType >::size | ( | void | ) |
Returns the number of items in the pool.
This function may be called from any thread.
void VuoKeyedPool< KeyType, InstanceType >::visit | ( | void(^)(KeyType, InstanceType) | b | ) |
Invokes block
on each item in the pool.
This function may be called from any thread.