|
Gaudi Framework, version v21r8 |
| Home | Generated: 17 Mar 2010 |
#include <GaudiKernel/AllocatorPool.h>

Public Member Functions | |
| AllocatorPool (unsigned int n=0) | |
| Create a pool of elements of size n. | |
| ~AllocatorPool () | |
| Destructor. Return storage to the free store. | |
| AllocatorPool (const AllocatorPool &right) | |
| Copy constructor. | |
| void * | Alloc () |
| Allocate one element. | |
| void | Free (void *b) |
| Return an element back to the pool. | |
| unsigned int | Size () const |
| Return storage size. | |
| void | Reset () |
| Return storage to the free store. | |
Private Member Functions | |
| AllocatorPool & | operator= (const AllocatorPool &right) |
| Private equality operator. | |
| void | Grow () |
| Make pool larger. | |
Private Attributes | |
| const unsigned int | esize |
| const unsigned int | csize |
| PoolChunk * | chunks |
| PoolLink * | head |
| int | nchunks |
Classes | |
| class | PoolChunk |
| struct | PoolLink |
Class is imported from Geant4 project
Definition at line 65 of file AllocatorPool.h.
| GaudiUtils::AllocatorPool::AllocatorPool | ( | unsigned int | n = 0 |
) | [explicit] |
| GaudiUtils::AllocatorPool::~AllocatorPool | ( | ) |
Destructor. Return storage to the free store.
Definition at line 88 of file AllocatorPool.cpp.
00089 { 00090 Reset(); 00091 }
| GaudiUtils::AllocatorPool::AllocatorPool | ( | const AllocatorPool & | right | ) |
| void * GaudiUtils::AllocatorPool::Alloc | ( | ) | [inline] |
| void GaudiUtils::AllocatorPool::Free | ( | void * | b | ) | [inline] |
| unsigned int GaudiUtils::AllocatorPool::Size | ( | ) | const [inline] |
| void GaudiUtils::AllocatorPool::Reset | ( | void | ) |
Return storage to the free store.
Definition at line 97 of file AllocatorPool.cpp.
00098 { 00099 // Free all chunks 00100 // 00101 PoolChunk* n = chunks; 00102 PoolChunk* p = 0; 00103 while (n) 00104 { 00105 p = n; 00106 n = n->next; 00107 delete p; 00108 } 00109 head = 0; 00110 chunks = 0; 00111 nchunks = 0; 00112 }
| GaudiUtils::AllocatorPool & GaudiUtils::AllocatorPool::operator= | ( | const AllocatorPool & | right | ) | [private] |
| void GaudiUtils::AllocatorPool::Grow | ( | ) | [private] |
Make pool larger.
Definition at line 118 of file AllocatorPool.cpp.
00119 { 00120 // Allocate new chunk, organize it as a linked list of 00121 // elements of size 'esize' 00122 // 00123 PoolChunk* n = new PoolChunk(csize); 00124 n->next = chunks; 00125 chunks = n; 00126 nchunks++; 00127 00128 const int nelem = csize/esize; 00129 char* start = n->mem; 00130 char* last = &start[(nelem-1)*esize]; 00131 for (char* p=start; p<last; p+=esize) 00132 { 00133 reinterpret_cast<PoolLink*>(p)->next 00134 = reinterpret_cast<PoolLink*>(p+esize); 00135 } 00136 reinterpret_cast<PoolLink*>(last)->next = 0; 00137 head = reinterpret_cast<PoolLink*>(start); 00138 }
const unsigned int GaudiUtils::AllocatorPool::esize [private] |
Definition at line 111 of file AllocatorPool.h.
const unsigned int GaudiUtils::AllocatorPool::csize [private] |
Definition at line 112 of file AllocatorPool.h.
PoolChunk* GaudiUtils::AllocatorPool::chunks [private] |
Definition at line 113 of file AllocatorPool.h.
PoolLink* GaudiUtils::AllocatorPool::head [private] |
Definition at line 114 of file AllocatorPool.h.
int GaudiUtils::AllocatorPool::nchunks [private] |
Definition at line 115 of file AllocatorPool.h.