Vuo  2.3.2
Public Types | Public Member Functions | List of all members
VuoKeyedPool< KeyType, InstanceType > Class Template Reference

Description

template<typename KeyType, typename InstanceType>
class VuoKeyedPool< KeyType, InstanceType >

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...
 

Member Typedef Documentation

◆ AllocateFunctionType

template<typename KeyType , typename InstanceType >
typedef InstanceType(* VuoKeyedPool< KeyType, InstanceType >::AllocateFunctionType) (KeyType)

A function that allocates InstanceType for a given key.

Definition at line 28 of file VuoPool.hh.

Constructor & Destructor Documentation

◆ VuoKeyedPool()

template<typename KeyType , typename InstanceType >
VuoKeyedPool< KeyType, InstanceType >::VuoKeyedPool ( std::string  instanceTypeString,
AllocateFunctionType  allocate 
)

See VUOKEYEDPOOL_DEFINE.

Definition at line 62 of file VuoPool.hh.

Member Function Documentation

◆ getSharedInstance()

template<typename KeyType , typename InstanceType >
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.

◆ removeSharedInstance()

template<typename KeyType , typename InstanceType >
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.

◆ size()

template<typename KeyType , typename InstanceType >
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.

◆ visit()

template<typename KeyType , typename InstanceType >
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.


The documentation for this class was generated from the following file: