Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

MemoryPooled< T > Class Template Reference

Wraps around a class T and redefines new() and delete() member functions. More...

#include <mempool.h>

Inheritance diagram for MemoryPooled:

Inheritance graph
[legend]
Collaboration diagram for MemoryPooled< T >:

Collaboration graph
[legend]
List of all members.

Public Methods

 MemoryPooled ()
 ~MemoryPooled ()

Static Public Methods

void * operator new (size_t size)
 Allocate a single object. More...

void operator delete (void *dead, size_t size)
 Recycle a single object. More...

int FreeBlocks ()

Static Private Methods

MemoryPooled< T > * allocate_block ()
 Utility function. More...


Static Private Attributes

const int BLOCK_SIZE
MemoryPooled< T > * freelist

Detailed Description

template<class T>
class MemoryPooled< T >

Wraps around a class T and redefines new() and delete() member functions.

Allocates chunks of BLOCK_SIZE objects at a time, then gives them out and recycles them.

Definition at line 38 of file mempool.h.


Constructor & Destructor Documentation

template<class T>
MemoryPooled< T >::MemoryPooled   [inline]
 

Definition at line 41 of file mempool.h.

template<class T>
MemoryPooled< T >::~MemoryPooled   [inline]
 

Definition at line 42 of file mempool.h.


Member Function Documentation

template<class T>
MemoryPooled< T > * MemoryPooled< T >::allocate_block   [static, private]
 

Utility function.

Definition at line 85 of file mempool.h.

References MemoryPooled< T >::BLOCK_SIZE, and MemoryPooled< T >::next.

Referenced by MemoryPooled< T >::operator new().

template<class T>
int MemoryPooled< T >::FreeBlocks   [static]
 

Definition at line 117 of file mempool.h.

References MemoryPooled< T >::freelist, and MemoryPooled< T >::next.

template<class T>
void MemoryPooled< T >::operator delete void *    dead,
size_t    size
[static]
 

Recycle a single object.

Definition at line 100 of file mempool.h.

References MemoryPooled< T >::freelist, and MemoryPooled< T >::next.

template<class T>
void * MemoryPooled< T >::operator new size_t    size [static]
 

Allocate a single object.

Definition at line 64 of file mempool.h.

References MemoryPooled< T >::allocate_block(), MemoryPooled< T >::BLOCK_SIZE, MemoryPooled< T >::freelist, and MemoryPooled< T >::next.


Member Data Documentation

template<class T>
const int MemoryPooled< T >::BLOCK_SIZE [static, private]
 

Definition at line 57 of file mempool.h.

Referenced by MemoryPooled< T >::allocate_block(), and MemoryPooled< T >::operator new().

template<class T>
T MemoryPooled< T >::data [protected]
 

Definition at line 51 of file mempool.h.

template<class T>
MemoryPooled<T>* MemoryPooled< T >::freelist [static, private]
 

Definition at line 59 of file mempool.h.

Referenced by MemoryPooled< T >::FreeBlocks(), MemoryPooled< T >::operator delete(), and MemoryPooled< T >::operator new().

template<class T>
MemoryPooled<T>* MemoryPooled< T >::next [protected]
 

Definition at line 52 of file mempool.h.

Referenced by MemoryPooled< T >::allocate_block(), MemoryPooled< T >::FreeBlocks(), MemoryPooled< T >::operator delete(), and MemoryPooled< T >::operator new().


Generated on Wed May 29 11:37:26 2002 for MarkovPR by doxygen1.2.15