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

atlas::pool::Pool Class Reference

#include <pool.h>

List of all members.

Public Member Functions

 Pool (size_t a, size_t d)
 Creates a Pool for units of d_alignSize = max(a, machine word size) bytes.
 ~Pool ()
 Return the memory to the system.
size_t maxAlloc () const
size_t instance () const
void * allocate (size_t)
void deallocate (void *, size_t)

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 (size_t m)
 Allocates a new block for a memory request of 2^m units of size max(d_atomSize,sizeof(MemBlock*)).
void reportDestruction ()
 Writes down data about the memory usage of the pool.

Private Attributes

const size_t d_atomSize
 Size in machine words of each object stored in this Pool.
const size_t d_defaultRequest
 Each system memory request is of size (2^d_defaultRequest)(d_alignSize) machine words.
const size_t d_maxAlloc
const size_t d_alignSize
const size_t d_instance
 Which instance of Pool this is.
void * d_free [constants::sizeBits]
 Entry m (for 0 <= m < word size) is a pointer to the first free block of 2^m units of memory in the Pool.
size_t d_used [constants::sizeBits]
 Entry m (for 0 <= m < word size) tells how many blocks of 2^m units of memory have been assigned by this Pool.
size_t d_allocated [constants::sizeBits]
 Entry m (for 0 <= m < word size) tells how many blocks of 2^m units of memory have been prepared for use by this Pool.
std::vector< void * > d_systemAllocs
 Entry #j is a pointer to the beginning of the jth block (of size (d_Size)(2^d_defaultRequest)) assigned by the system to this Pool.

Static Private Attributes

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


Constructor & Destructor Documentation

atlas::pool::Pool::Pool size_t  a,
size_t  d
 

Creates a Pool for units of d_alignSize = max(a, machine word size) bytes.

Definition at line 129 of file pool.cpp.

References d_allocated, d_free, d_used, and atlas::constants::sizeBits.

atlas::pool::Pool::~Pool  ) 
 

Return the memory to the system.

Definition at line 151 of file pool.cpp.

References d_systemAllocs, instances, and memoryReport().


Member Function Documentation

void * atlas::pool::Pool::allocate size_t   ) 
 

Definition at line 172 of file pool.cpp.

References d_atomSize, d_free, atlas::pool::helper::MemBlock::d_next, d_used, atlas::bits::lastBit(), newBlock(), and atlas::pool::helper::reducedSize().

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

Definition at line 157 of file pool.h.

void atlas::pool::Pool::deallocate void *  ,
size_t 
 

Definition at line 199 of file pool.cpp.

References d_atomSize, d_free, atlas::pool::helper::MemBlock::d_next, d_used, atlas::bits::lastBit(), and atlas::pool::helper::reducedSize().

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

Definition at line 148 of file pool.h.

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

Definition at line 144 of file pool.h.

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

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

Definition at line 228 of file pool.cpp.

References atlas::pool::helper::PoolDestruct::d_allocated, atlas::pool::helper::PoolDestruct::d_instance, atlas::pool::helper::PoolDestruct::d_systemAllocs, logfile, atlas::pool::helper::poolDestructions, and atlas::constants::sizeBits.

Referenced by ~Pool().

void * atlas::pool::Pool::newBlock size_t  m  )  [private]
 

Allocates a new block for a memory request of 2^m units of size max(d_atomSize,sizeof(MemBlock*)).

Definition at line 264 of file pool.cpp.

References d_alignSize, d_allocated, d_defaultRequest, d_free, atlas::pool::helper::MemBlock::d_next, and d_systemAllocs.

Referenced by allocate().

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

Definition at line 161 of file pool.h.

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

Writes down data about the memory usage of the pool.

Definition at line 340 of file pool.cpp.

References d_allocated, atlas::pool::helper::PoolDestruct::d_allocated, atlas::pool::helper::PoolDestruct::d_instance, d_systemAllocs, atlas::pool::helper::PoolDestruct::d_systemAllocs, atlas::pool::helper::poolDestructions, and atlas::constants::sizeBits.


Member Data Documentation

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

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

Definition at line 36 of file pool.cpp.

const size_t atlas::pool::Pool::d_alignSize [private]
 

Definition at line 98 of file pool.h.

Referenced by newBlock().

size_t atlas::pool::Pool::d_allocated[constants::sizeBits] [private]
 

Entry m (for 0 <= m < word size) tells how many blocks of 2^m units of memory have been prepared for use by this Pool.

Definition at line 121 of file pool.h.

Referenced by newBlock(), Pool(), and reportDestruction().

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

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

Definition at line 86 of file pool.h.

Referenced by allocate(), and deallocate().

const size_t atlas::pool::Pool::d_defaultRequest [private]
 

Each system memory request is of size (2^d_defaultRequest)(d_alignSize) machine words.

Definition at line 92 of file pool.h.

Referenced by newBlock().

void* atlas::pool::Pool::d_free[constants::sizeBits] [private]
 

Entry m (for 0 <= m < word size) is a pointer to the first free block of 2^m units of memory in the Pool.

Definition at line 109 of file pool.h.

Referenced by allocate(), deallocate(), newBlock(), and Pool().

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

Which instance of Pool this is.

Definition at line 103 of file pool.h.

const size_t atlas::pool::Pool::d_maxAlloc [private]
 

Definition at line 97 of file pool.h.

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

Entry #j is a pointer to the beginning of the jth block (of size (d_Size)(2^d_defaultRequest)) assigned by the system to this Pool.

Each assignment is of (d_alignSize)(2^m) bytes, for some m >= d_defaultRequest.

Definition at line 131 of file pool.h.

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

size_t atlas::pool::Pool::d_used[constants::sizeBits] [private]
 

Entry m (for 0 <= m < word size) tells how many blocks of 2^m units of memory have been assigned by this Pool.

Definition at line 115 of file pool.h.

Referenced by allocate(), deallocate(), and Pool().

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

Definition at line 38 of file pool.cpp.

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

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

Definition at line 35 of file pool.cpp.

Referenced by ~Pool().

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

Report on the activity of Pool.

Definition at line 37 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