Vuo  1.0.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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.

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.
 

Member Typedef Documentation

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

A function that allocates InstanceType for a given key.

Constructor & Destructor Documentation

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

Member Function Documentation

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.

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.

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.

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.


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