Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4AllocatorPool Class Reference

#include <G4AllocatorPool.hh>

Public Member Functions

 G4AllocatorPool (unsigned int n=0)
 
 ~G4AllocatorPool ()
 
voidAlloc ()
 
void Free (void *b)
 
unsigned int Size () const
 
void Reset ()
 
int GetNoPages () const
 
unsigned int GetPageSize () const
 
void GrowPageSize (unsigned int factor)
 

Detailed Description

Definition at line 50 of file G4AllocatorPool.hh.

Constructor & Destructor Documentation

G4AllocatorPool::G4AllocatorPool ( unsigned int  n = 0)
explicit

Definition at line 44 of file G4AllocatorPool.cc.

45  : esize(sz<sizeof(G4PoolLink) ? sizeof(G4PoolLink) : sz),
46  csize(sz<1024/2-16 ? 1024-16 : sz*10-16),
47  chunks(0), head(0), nchunks(0)
48 {
49 }
G4AllocatorPool::~G4AllocatorPool ( )

Definition at line 79 of file G4AllocatorPool.cc.

80 {
81  Reset();
82 }

Here is the call graph for this function:

Member Function Documentation

void * G4AllocatorPool::Alloc ( )
inline

Definition at line 119 of file G4AllocatorPool.hh.

120 {
121  if (head==0) { Grow(); }
122  G4PoolLink* p = head; // return first element
123  head = p->next;
124  return p;
125 }
const char * p
Definition: xmltok.h:285
void G4AllocatorPool::Free ( void b)
inline

Definition at line 132 of file G4AllocatorPool.hh.

133 {
134  G4PoolLink* p = static_cast<G4PoolLink*>(b);
135  p->next = head; // put b back as first element
136  head = p;
137 }
const char * p
Definition: xmltok.h:285
int G4AllocatorPool::GetNoPages ( ) const
inline

Definition at line 154 of file G4AllocatorPool.hh.

155 {
156  return nchunks;
157 }
unsigned int G4AllocatorPool::GetPageSize ( ) const
inline

Definition at line 164 of file G4AllocatorPool.hh.

165 {
166  return csize;
167 }
void G4AllocatorPool::GrowPageSize ( unsigned int  factor)
inline

Definition at line 174 of file G4AllocatorPool.hh.

175 {
176  csize = (sz) ? sz*csize : csize;
177 }
void G4AllocatorPool::Reset ( )

Definition at line 88 of file G4AllocatorPool.cc.

89 {
90  // Free all chunks
91  //
92  G4PoolChunk* n = chunks;
93  G4PoolChunk* p = 0;
94  while (n)
95  {
96  p = n;
97  n = n->next;
98  delete p;
99  }
100  head = 0;
101  chunks = 0;
102  nchunks = 0;
103 }
const char * p
Definition: xmltok.h:285

Here is the caller graph for this function:

unsigned int G4AllocatorPool::Size ( ) const
inline

Definition at line 144 of file G4AllocatorPool.hh.

145 {
146  return nchunks*csize;
147 }

The documentation for this class was generated from the following files: