mems::SlotAllocator< T > Class Template Reference

This class allocates memory according to the slot allocation scheme for fixed size objects. More...

#include <SlotAllocator.h>

List of all members.

Public Member Functions

T * Allocate ()
void Free (std::vector< T * > &chunk)
void Free (T *t)
void Purge ()
 ~SlotAllocator ()

Static Public Member Functions

SlotAllocator< T > & GetSlotAllocator ()

Protected Attributes

TLS< std::vector< T * > > data
TLS< std::vector< T * > > free_list
TLS< unsigned > n_elems
 number of T in the most recently allocated block

TLS< unsigned > tail_free

Private Member Functions

SlotAllocatoroperator= (SlotAllocator &sa)
 SlotAllocator (SlotAllocator &sa)
 SlotAllocator ()


Detailed Description

template<class T>
class mems::SlotAllocator< T >

This class allocates memory according to the slot allocation scheme for fixed size objects.

Each time all slots are full it allocates twice the previous allocation. If it is unable to allocate twice the previous allocation, it does a binary 'search' for the largest amount of memory it can allocate. The current implementation does not allow memory to be freed once allocated.

Definition at line 39 of file SlotAllocator.h.


Constructor & Destructor Documentation

template<class T>
mems::SlotAllocator< T >::~SlotAllocator  )  [inline]
 

Definition at line 45 of file SlotAllocator.h.

template<class T>
mems::SlotAllocator< T >::SlotAllocator  )  [inline, private]
 

Definition at line 72 of file SlotAllocator.h.

template<class T>
mems::SlotAllocator< T >::SlotAllocator SlotAllocator< T > &  sa  )  [inline, private]
 

Definition at line 74 of file SlotAllocator.h.


Member Function Documentation

template<class T>
T * mems::SlotAllocator< T >::Allocate  )  [inline]
 

Definition at line 88 of file SlotAllocator.h.

References mems::SlotAllocator< T >::free_list, mems::SlotAllocator< T >::n_elems, mems::POOL_GROWTH_RATE, and mems::SlotAllocator< T >::tail_free.

template<class T>
void mems::SlotAllocator< T >::Free std::vector< T * > &  chunk  )  [inline]
 

Definition at line 152 of file SlotAllocator.h.

References mems::SlotAllocator< T >::free_list.

template<class T>
void mems::SlotAllocator< T >::Free T *  t  )  [inline]
 

Definition at line 135 of file SlotAllocator.h.

References mems::SlotAllocator< T >::free_list.

template<class T>
SlotAllocator< T > & mems::SlotAllocator< T >::GetSlotAllocator  )  [inline, static]
 

Definition at line 80 of file SlotAllocator.h.

template<class T>
SlotAllocator& mems::SlotAllocator< T >::operator= SlotAllocator< T > &  sa  )  [inline, private]
 

Definition at line 73 of file SlotAllocator.h.

template<class T>
void mems::SlotAllocator< T >::Purge  )  [inline]
 

Definition at line 48 of file SlotAllocator.h.

Referenced by mems::SlotAllocator< MatchHashEntry >::~SlotAllocator().


Member Data Documentation

template<class T>
TLS< std::vector<T*> > mems::SlotAllocator< T >::data [protected]
 

Definition at line 65 of file SlotAllocator.h.

Referenced by mems::SlotAllocator< MatchHashEntry >::operator=().

template<class T>
TLS< std::vector< T* > > mems::SlotAllocator< T >::free_list [protected]
 

Definition at line 69 of file SlotAllocator.h.

Referenced by mems::SlotAllocator< T >::Allocate(), and mems::SlotAllocator< T >::Free().

template<class T>
TLS< unsigned > mems::SlotAllocator< T >::n_elems [protected]
 

number of T in the most recently allocated block

Definition at line 67 of file SlotAllocator.h.

Referenced by mems::SlotAllocator< T >::Allocate(), and mems::SlotAllocator< MatchHashEntry >::operator=().

template<class T>
TLS< unsigned > mems::SlotAllocator< T >::tail_free [protected]
 

Definition at line 66 of file SlotAllocator.h.

Referenced by mems::SlotAllocator< T >::Allocate(), and mems::SlotAllocator< MatchHashEntry >::operator=().


The documentation for this class was generated from the following file:
Generated on Fri Mar 14 06:01:43 2008 for libMems by doxygen 1.3.6