Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core::Pool< T > Class Template Reference

Pool. More...

#include <pool.h>

Inheritance diagram for roc::core::Pool< T >:
Collaboration diagram for roc::core::Pool< T >:

Public Member Functions

 Pool (IAllocator &allocator, size_t object_size, bool poison)
 Initialization. More...
void * allocate ()
 Allocate new object. More...
void deallocate (void *memory)
 Free previously allocated memory. More...
void destroy (T &object)
 Destroy object and deallocate its memory. More...

Detailed Description

template<class T>
class roc::core::Pool< T >


Template Parameters
Tdefines object type.

Allocates chunks from given allocator containing a fixed number of fixed sized objects. Maintains a list of free objects.

The memory is always maximum aligned. Thread-safe.

Definition at line 35 of file pool.h.

Constructor & Destructor Documentation

template<class T>
roc::core::Pool< T >::Pool ( IAllocator allocator,
size_t  object_size,
bool  poison 



  • allocator is used to allocate chunks
  • object_size defines object size in bytes
  • poison enables memory poisoning for debugging

Definition at line 43 of file pool.h.

Member Function Documentation

template<class T>
void* roc::core::Pool< T >::allocate ( )

Allocate new object.

pointer to a maximum aligned uninitialized memory for a new object or NULL if memory can't be allocated.

Definition at line 62 of file pool.h.

template<class T>
void roc::core::Pool< T >::deallocate ( void *  memory)

Free previously allocated memory.

Definition at line 82 of file pool.h.

template<class T>
void roc::core::Pool< T >::destroy ( T &  object)

Destroy object and deallocate its memory.

Definition at line 96 of file pool.h.

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