Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

atlas::pool::SimplePool Class Reference

Pool for allocating memory in small units. More...

#include <pool.h>

List of all members.

Public Member Functions

 SimplePool (size_t, size_t)
 ~SimplePool ()
 Return the memory to the system.
size_t maxAlloc () const
size_t instance () const
void * allocate (size_t n)
 Returns a pointer to the beginning of n units of memory in this SimplePool.
void deallocate (void *ptr, size_t n)
 Does nothing!

Static Public Member Functions

void allowReport ()
size_t numInstances ()
void memoryReport ()
 Writes a report on the various pool constructions and destructions in the memory log file.

Private Member Functions

void * newBlock ()
void reportDestruction ()
 Writes down data about the memory usage of the pool.

Private Attributes

const size_t d_systemRequest
const size_t d_atomSize
 Size in machine words of each object stored in this SimplePool.
const size_t d_instance
 Which instance of SimplePool this is.
char * d_free
 Pointer to the first free unit of memory in this SimplePool.
char * d_top
 Pointer to the first byte beyond the available memory in this simple pool.
size_t d_used
 Tells how many units of memory have been assigned by this SimplePool.
size_t d_allocated
 Tells how many units of memory have been prepared for use by this SimplePool.
std::vector< void * > d_systemAllocs
 Entry #j is a pointer to the beginning of the jth block (of size (d_atomSize)(2^d_systemRequest)) assigned by the system to this SimplePool.

Static Private Attributes

size_t instances = 0
 Incremented each time SimplePool is instantiated, and decremented when a SimplePool is destroyed, so that it counts the number of SimplePool's.
size_t constructions = 0
 Incremented each time SimplePool is instantiated, but not decremented when a SimplePool is destroyed.
const char * logfile = "simplepool.log"
 Report on the activity of SimplePool.
bool done = false


Detailed Description

Pool for allocating memory in small units.

Each allocation will be of size d_atomSize. Memory is requested from the system in blocks of size (d_atomSize)(2^d_systemRequest); pointers to the beginning of each such request are in d_systemAllocs.

Definition at line 175 of file pool.h.


Constructor & Destructor Documentation

atlas::pool::SimplePool::SimplePool size_t  ,
size_t 
 

Definition at line 374 of file pool.cpp.

atlas::pool::SimplePool::~SimplePool  ) 
 

Return the memory to the system.

Definition at line 387 of file pool.cpp.

References d_systemAllocs, instances, memoryReport(), and reportDestruction().


Member Function Documentation

void * atlas::pool::SimplePool::allocate size_t  n  ) 
 

Returns a pointer to the beginning of n units of memory in this SimplePool.

It is required that n = 1, or there will be serious memory problems.

Definition at line 404 of file pool.cpp.

References d_free, and newBlock().

void atlas::pool::SimplePool::allowReport  )  [inline, static]
 

Definition at line 279 of file pool.h.

void atlas::pool::SimplePool::deallocate void *  ptr,
size_t  n
 

Does nothing!

It is required that n = 1, or there will be serious memory problems.

Definition at line 420 of file pool.cpp.

size_t atlas::pool::SimplePool::instance  )  const [inline]
 

Definition at line 258 of file pool.h.

size_t atlas::pool::SimplePool::maxAlloc  )  const [inline]
 

Definition at line 254 of file pool.h.

void atlas::pool::SimplePool::memoryReport  )  [static]
 

Writes a report on the various pool constructions and destructions in the memory log file.

Definition at line 431 of file pool.cpp.

References atlas::pool::helper::SimplePoolDestruct::d_allocated, atlas::pool::helper::SimplePoolDestruct::d_instance, atlas::pool::helper::SimplePoolDestruct::d_systemAllocs, logfile, and atlas::pool::helper::simplePoolDestructions.

Referenced by ~SimplePool().

void * atlas::pool::SimplePool::newBlock  )  [private]
 

Definition at line 463 of file pool.cpp.

References d_allocated, d_atomSize, d_free, d_systemAllocs, d_systemRequest, and d_top.

Referenced by allocate().

size_t atlas::pool::SimplePool::numInstances  )  [inline, static]
 

Definition at line 283 of file pool.h.

void atlas::pool::SimplePool::reportDestruction  )  [private]
 

Writes down data about the memory usage of the pool.

Definition at line 490 of file pool.cpp.

References atlas::pool::helper::SimplePoolDestruct::d_allocated, atlas::pool::helper::SimplePoolDestruct::d_instance, d_systemAllocs, atlas::pool::helper::SimplePoolDestruct::d_systemAllocs, and atlas::pool::helper::simplePoolDestructions.

Referenced by ~SimplePool().


Member Data Documentation

size_t atlas::pool::SimplePool::constructions = 0 [static, private]
 

Incremented each time SimplePool is instantiated, but not decremented when a SimplePool is destroyed.

Definition at line 41 of file pool.cpp.

size_t atlas::pool::SimplePool::d_allocated [private]
 

Tells how many units of memory have been prepared for use by this SimplePool.

Definition at line 234 of file pool.h.

Referenced by newBlock().

const size_t atlas::pool::SimplePool::d_atomSize [private]
 

Size in machine words of each object stored in this SimplePool.

Definition at line 203 of file pool.h.

Referenced by newBlock().

char* atlas::pool::SimplePool::d_free [private]
 

Pointer to the first free unit of memory in this SimplePool.

Definition at line 214 of file pool.h.

Referenced by allocate(), and newBlock().

const size_t atlas::pool::SimplePool::d_instance [private]
 

Which instance of SimplePool this is.

Definition at line 208 of file pool.h.

std::vector<void*> atlas::pool::SimplePool::d_systemAllocs [private]
 

Entry #j is a pointer to the beginning of the jth block (of size (d_atomSize)(2^d_systemRequest)) assigned by the system to this SimplePool.

Definition at line 241 of file pool.h.

Referenced by newBlock(), reportDestruction(), and ~SimplePool().

const size_t atlas::pool::SimplePool::d_systemRequest [private]
 

Definition at line 198 of file pool.h.

Referenced by newBlock().

char* atlas::pool::SimplePool::d_top [private]
 

Pointer to the first byte beyond the available memory in this simple pool.

Refers always to the most recent system allocation.

Definition at line 222 of file pool.h.

Referenced by newBlock().

size_t atlas::pool::SimplePool::d_used [private]
 

Tells how many units of memory have been assigned by this SimplePool.

Definition at line 228 of file pool.h.

bool atlas::pool::SimplePool::done = false [static, private]
 

Definition at line 43 of file pool.cpp.

size_t atlas::pool::SimplePool::instances = 0 [static, private]
 

Incremented each time SimplePool is instantiated, and decremented when a SimplePool is destroyed, so that it counts the number of SimplePool's.

Definition at line 40 of file pool.cpp.

Referenced by ~SimplePool().

const char * atlas::pool::SimplePool::logfile = "simplepool.log" [static, private]
 

Report on the activity of SimplePool.

Definition at line 42 of file pool.cpp.

Referenced by memoryReport().


The documentation for this class was generated from the following files:
Generated on Wed Mar 26 16:53:00 2008 for atlas by  doxygen 1.3.9.1