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.
Definition at line 24 of file VuoPool.hh.
Public Types | |
typedef InstanceType(* | AllocateFunctionType) (KeyType) |
A function that allocates InstanceType for a given key. More... | |
Public Member Functions | |
VuoKeyedPool (std::string instanceTypeString, AllocateFunctionType allocate) | |
See VUOKEYEDPOOL_DEFINE. More... | |
InstanceType | getSharedInstance (KeyType key) |
Returns a shared object for the specified key , allocating it if necessary. More... | |
void | removeSharedInstance (KeyType key) |
Removes key from the pool. More... | |
void | visit (void(^b)(KeyType, InstanceType)) |
Invokes block on each item in the pool. More... | |
unsigned int | size (void) |
Returns the number of items in the pool. More... | |
typedef InstanceType(* VuoKeyedPool< KeyType, InstanceType >::AllocateFunctionType) (KeyType) |
A function that allocates InstanceType
for a given key.
Definition at line 28 of file VuoPool.hh.
VuoKeyedPool< KeyType, InstanceType >::VuoKeyedPool | ( | std::string | instanceTypeString, |
AllocateFunctionType | allocate | ||
) |
See VUOKEYEDPOOL_DEFINE.
Definition at line 62 of file VuoPool.hh.
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.
Definition at line 76 of file VuoPool.hh.
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.
Definition at line 100 of file VuoPool.hh.
unsigned int VuoKeyedPool< KeyType, InstanceType >::size | ( | void | ) |
Returns the number of items in the pool.
This function may be called from any thread.
Definition at line 128 of file VuoPool.hh.
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.
Definition at line 114 of file VuoPool.hh.