pion::PionPoolAllocator< MinSize, MaxSize > Class Template Reference

#include <PionPoolAllocator.hpp>

List of all members.


Detailed Description

template<std::size_t MinSize = 16, std::size_t MaxSize = 256>
class pion::PionPoolAllocator< MinSize, MaxSize >

PionPoolAllocator: a thread-safe, small object allocator that sacrifices memory utilization for performance. It combines a collection of fixed-size pooled memory allocators with lock-free caches to achieve nearly wait-free, constant time performance when used for an extended period of time

Definition at line 48 of file PionPoolAllocator.hpp.

Public Member Functions

virtual ~PionPoolAllocator ()
 virtual destructor
 PionPoolAllocator (void)
 default constructor
void * malloc (std::size_t n)
void free (void *ptr, std::size_t n)
bool release_memory (void)

Protected Types

typedef void * FreeListPtr
 NumberOfAllocs = ((MaxSize-1) / MinSize) + 1
enum  { NumberOfAllocs = ((MaxSize-1) / MinSize) + 1 }
 constant representing the number of fixed-size pool allocators

Protected Member Functions

 BOOST_STATIC_ASSERT (MaxSize >=MinSize)
 BOOST_STATIC_ASSERT (MaxSize%MinSize==0)
FixedSizeAllocgetPool (const std::size_t n)

Classes

struct  FixedSizeAlloc


Member Function Documentation

template<std::size_t MinSize = 16, std::size_t MaxSize = 256>
pion::PionPoolAllocator< MinSize, MaxSize >::BOOST_STATIC_ASSERT ( MaxSize >=  MinSize  )  [protected]

ensure that: a) MaxSize >= MinSize b) MaxSize is a multiple of MinSize c) MinSize >= sizeof(FreeNodePtr) [usually 16]

template<std::size_t MinSize = 16, std::size_t MaxSize = 256>
void pion::PionPoolAllocator< MinSize, MaxSize >::free ( void *  ptr,
std::size_t  n 
) [inline]

deallocates a block of memory

Parameters:
ptr raw pointer to the block of memory
n requested size of the memory block, in bytes (actual size may be larger)

Definition at line 102 of file PionPoolAllocator.hpp.

References pion::PionPoolAllocator< MinSize, MaxSize >::getPool(), pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_free_ptr, pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_mutex, and pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_pool.

template<std::size_t MinSize = 16, std::size_t MaxSize = 256>
FixedSizeAlloc* pion::PionPoolAllocator< MinSize, MaxSize >::getPool ( const std::size_t  n  )  [inline, protected]

gets an appropriate fixed-size pool allocator

Parameters:
n the number of bytes to be (de)allocated
Returns:
FixedSizeAlloc* pointer to the appropriate fixed-size allocator

Definition at line 210 of file PionPoolAllocator.hpp.

Referenced by pion::PionPoolAllocator< MinSize, MaxSize >::free(), and pion::PionPoolAllocator< MinSize, MaxSize >::malloc().

template<std::size_t MinSize = 16, std::size_t MaxSize = 256>
void* pion::PionPoolAllocator< MinSize, MaxSize >::malloc ( std::size_t  n  )  [inline]

allocates a block of memory

Parameters:
n minimum size of the new memory block, in bytes
Returns:
void * raw pointer to the new memory block

Definition at line 72 of file PionPoolAllocator.hpp.

References pion::PionPoolAllocator< MinSize, MaxSize >::getPool(), pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_free_ptr, pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_mutex, and pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_pool.

template<std::size_t MinSize = 16, std::size_t MaxSize = 256>
bool pion::PionPoolAllocator< MinSize, MaxSize >::release_memory ( void   )  [inline]

releases every memory block that does not have any allocated chunks

Parameters:
bool true if at least one block of memory was released

Definition at line 135 of file PionPoolAllocator.hpp.


The documentation for this class was generated from the following file:
Generated on Fri Apr 30 14:48:54 2010 for pion-net by  doxygen 1.4.7