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

MemPool< S > Class Template Reference

A memory managed class suitable for many small arrays of type S. More...

#include <mempool.h>

Inheritance diagram for MemPool:

Inheritance graph
[legend]
Collaboration diagram for MemPool< S >:

Collaboration graph
[legend]
List of all members.

Public Methods

 MemPool ()
 ~MemPool ()
MemPoolObject< S > * Allocate (int numels) throw (range_error)
void Deallocate (MemPoolObject< S > *dead, int numels)

Static Public Methods

int FreeBlocks1 ()
int FreeBlocks2 ()

Static Private Methods

MemPoolObject< S > * allocate_block1 ()
MemPoolObject< S > * allocate_block2 ()

Static Private Attributes

const int BLOCK_SIZE
MemPoolObject< S > * mempool1
 mempool1 contains only single chunks. More...

MemPoolObject< S > * mempool2
 mempool2 contains blocks of chunks suitable for arrays. More...


Detailed Description

template<class S>
class MemPool< S >

A memory managed class suitable for many small arrays of type S.

This memory pool class handles memory management for large numbers of small arrays whose elements are of type S. The normal new[] and delete[] functions for S objects introduce much overhead, so they aren't suitable for the "fromlinks" and "tolinks" Link arrays associated with each WebNode. Instead, MemPool<S> provides Allocate() and Deallocate() member functions to replace new[] and delete[].

Definition at line 159 of file mempool.h.


Constructor & Destructor Documentation

template<class S>
MemPool< S >::MemPool   [inline]
 

Definition at line 163 of file mempool.h.

template<class S>
MemPool< S >::~MemPool   [inline]
 

Definition at line 164 of file mempool.h.


Member Function Documentation

template<class S>
MemPoolObject< S > * MemPool< S >::Allocate int    numels throw (range_error)
 

Definition at line 182 of file mempool.h.

References MemPoolObject< S >::admin_length, MemPoolObject< S >::admin_next, and NULL.

template<class S>
MemPoolObject< S > * MemPool< S >::allocate_block1   [static, private]
 

Definition at line 256 of file mempool.h.

References MemPoolObject< S >::admin_next, and MemPool< S >::BLOCK_SIZE.

template<class S>
MemPoolObject< S > * MemPool< S >::allocate_block2   [static, private]
 

Definition at line 269 of file mempool.h.

References MemPoolObject< S >::admin_length, MemPoolObject< S >::admin_next, and MemPool< S >::BLOCK_SIZE.

template<class S>
void MemPool< S >::Deallocate MemPoolObject< S > *    dead,
int    numels
 

Definition at line 301 of file mempool.h.

References MemPoolObject< S >::admin_length, MemPoolObject< S >::admin_next, MemPool< S >::mempool1, and MemPool< S >::mempool2.

template<class S>
int MemPool< S >::FreeBlocks1   [static]
 

Definition at line 279 of file mempool.h.

References MemPoolObject< S >::admin_next, and MemPool< S >::mempool1.

Referenced by GraphBuilder::StatisticsMem().

template<class S>
int MemPool< S >::FreeBlocks2   [static]
 

Definition at line 290 of file mempool.h.

References MemPoolObject< S >::admin_length, MemPoolObject< S >::admin_next, and MemPool< S >::mempool2.

Referenced by GraphBuilder::StatisticsMem().


Member Data Documentation

template<class S>
const int MemPool< S >::BLOCK_SIZE [static, private]
 

Definition at line 173 of file mempool.h.

Referenced by MemPool< S >::allocate_block1(), and MemPool< S >::allocate_block2().

template<class S>
MemPoolObject<S>* MemPool< S >::mempool1 [static, private]
 

mempool1 contains only single chunks.

Definition at line 177 of file mempool.h.

Referenced by MemPool< S >::Deallocate(), and MemPool< S >::FreeBlocks1().

template<class S>
MemPoolObject<S>* MemPool< S >::mempool2 [static, private]
 

mempool2 contains blocks of chunks suitable for arrays.

Definition at line 178 of file mempool.h.

Referenced by MemPool< S >::Deallocate(), and MemPool< S >::FreeBlocks2().


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