G4AllocatorPool Class Reference

#include <G4AllocatorPool.hh>


Public Member Functions

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

Data Structures

class  G4PoolChunk
struct  G4PoolLink


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.

00045   : esize(sz<sizeof(G4PoolLink) ? sizeof(G4PoolLink) : sz),
00046     csize(sz<1024/2-16 ? 1024-16 : sz*10-16),
00047     chunks(0), head(0), nchunks(0)
00048 {
00049 }

G4AllocatorPool::~G4AllocatorPool (  ) 

Definition at line 79 of file G4AllocatorPool.cc.

References Reset().

00080 {
00081   Reset();
00082 }


Member Function Documentation

void * G4AllocatorPool::Alloc (  )  [inline]

Definition at line 119 of file G4AllocatorPool.hh.

Referenced by G4Allocator< Type >::MallocSingle().

00120 {
00121   if (head==0) { Grow(); }
00122   G4PoolLink* p = head;  // return first element
00123   head = p->next;
00124   return p;
00125 }

void G4AllocatorPool::Free ( void *  b  )  [inline]

Definition at line 132 of file G4AllocatorPool.hh.

Referenced by G4Allocator< Type >::FreeSingle().

00133 {
00134   G4PoolLink* p = static_cast<G4PoolLink*>(b);
00135   p->next = head;        // put b back as first element
00136   head = p;
00137 }

int G4AllocatorPool::GetNoPages (  )  const [inline]

Definition at line 154 of file G4AllocatorPool.hh.

Referenced by G4Allocator< Type >::GetNoPages().

00155 {
00156   return nchunks;
00157 }

unsigned int G4AllocatorPool::GetPageSize (  )  const [inline]

Definition at line 164 of file G4AllocatorPool.hh.

Referenced by G4Allocator< Type >::GetPageSize().

00165 {
00166   return csize;
00167 }

void G4AllocatorPool::GrowPageSize ( unsigned int  factor  )  [inline]

Definition at line 174 of file G4AllocatorPool.hh.

Referenced by G4Allocator< Type >::IncreasePageSize().

00175 {
00176   csize = (sz) ? sz*csize : csize; 
00177 }

void G4AllocatorPool::Reset (  ) 

Definition at line 88 of file G4AllocatorPool.cc.

References CLHEP::detail::n.

Referenced by G4Allocator< Type >::ResetStorage(), and ~G4AllocatorPool().

00089 {
00090   // Free all chunks
00091   //
00092   G4PoolChunk* n = chunks;
00093   G4PoolChunk* p = 0;
00094   while (n)
00095   {
00096     p = n;
00097     n = n->next;
00098     delete p;
00099   }
00100   head = 0;
00101   chunks = 0;
00102   nchunks = 0;
00103 }

unsigned int G4AllocatorPool::Size (  )  const [inline]

Definition at line 144 of file G4AllocatorPool.hh.

Referenced by G4Allocator< Type >::GetAllocatedSize().

00145 {
00146   return nchunks*csize;
00147 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:51:25 2013 for Geant4 by  doxygen 1.4.7