Zero  0.1.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Pool Class Reference

Simple pool class. More...

#include <stl_pool.h>

Public Member Functions

 Pool (size_t granularity, size_t size)
 Allocates a pool with size elements each of granularity bytes. More...
 
 ~Pool ()
 Checks for emptiness before destructing. More...
 
size_t GetGranularity () const
 Gets the pool granularity. More...
 
size_t GetSize () const
 Gets the pool size in elements. More...
 
size_t GetUsed () const
 Gets the number of elements allocated from pooled storage. More...
 
size_t GetOverflow () const
 Gets the number of elements allocated from non-pooled storage. More...
 
void * Allocate ()
 Allocates memory from the pool without construction. More...
 
void Deallocate (void *block)
 Deallocates memory from the pool without destruction. More...
 
template<typename T >
TConstruct ()
 Constructs an object from the pool. More...
 
template<typename T >
void Destroy (T *instance)
 Destructs an object back into the pool. More...
 

Private Member Functions

bool IsFromPool (void const *instance) const
 Returns true if the given instance is from pooled storage. More...
 

Private Attributes

size_t m_granularity
 The size of each element in the pool in bytes. More...
 
size_t m_size
 The number of elements in pooled storage. More...
 
size_t volatile m_used
 The number of pooled allocations. More...
 
size_t volatile m_overflow
 The number of non-pooled allocations. More...
 
array_guard_t< char > m_storage
 The pool storage. More...
 
array_guard_t< void * > m_slots
 The free list. More...
 

Detailed Description

Simple pool class.

Constructor & Destructor Documentation

§ Pool()

Pool::Pool ( size_t  granularity,
size_t  size 
)

Allocates a pool with size elements each of granularity bytes.

§ ~Pool()

Pool::~Pool ( )

Checks for emptiness before destructing.

Member Function Documentation

§ Allocate()

void * Pool::Allocate ( )

Allocates memory from the pool without construction.

§ Construct()

template<typename T >
T* Pool::Construct ( )
inline

Constructs an object from the pool.

§ Deallocate()

void Pool::Deallocate ( void *  block)

Deallocates memory from the pool without destruction.

§ Destroy()

template<typename T >
void Pool::Destroy ( T instance)
inline

Destructs an object back into the pool.

§ GetGranularity()

size_t Pool::GetGranularity ( ) const
inline

Gets the pool granularity.

§ GetOverflow()

size_t Pool::GetOverflow ( ) const
inline

Gets the number of elements allocated from non-pooled storage.

§ GetSize()

size_t Pool::GetSize ( ) const
inline

Gets the pool size in elements.

§ GetUsed()

size_t Pool::GetUsed ( ) const
inline

Gets the number of elements allocated from pooled storage.

§ IsFromPool()

bool Pool::IsFromPool ( void const *  instance) const
inlineprivate

Returns true if the given instance is from pooled storage.

Member Data Documentation

§ m_granularity

size_t Pool::m_granularity
private

The size of each element in the pool in bytes.

§ m_overflow

size_t volatile Pool::m_overflow
private

The number of non-pooled allocations.

§ m_size

size_t Pool::m_size
private

The number of elements in pooled storage.

§ m_slots

array_guard_t<void*> Pool::m_slots
private

The free list.

§ m_storage

array_guard_t<char> Pool::m_storage
private

The pool storage.

§ m_used

size_t volatile Pool::m_used
private

The number of pooled allocations.


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