Geant4  10.02.p03
G4INCL::AllocationPool< T > Class Template Reference

#include <G4INCLAllocationPool.hh>

Collaboration diagram for G4INCL::AllocationPool< T >:

Public Member Functions

T * getObject ()
 
void recycleObject (T *t)
 
void clear ()
 

Static Public Member Functions

static AllocationPoolgetInstance ()
 

Protected Member Functions

 AllocationPool ()
 
virtual ~AllocationPool ()
 

Protected Attributes

std::stack< T * > theStack
 

Static Protected Attributes

static G4ThreadLocal AllocationPooltheInstance = 0
 

Detailed Description

template<typename T>
class G4INCL::AllocationPool< T >

Definition at line 55 of file G4INCLAllocationPool.hh.

Constructor & Destructor Documentation

◆ AllocationPool()

template<typename T>
G4INCL::AllocationPool< T >::AllocationPool ( )
inlineprotected

Definition at line 85 of file G4INCLAllocationPool.hh.

85 {}

◆ ~AllocationPool()

template<typename T>
virtual G4INCL::AllocationPool< T >::~AllocationPool ( )
inlineprotectedvirtual

Definition at line 86 of file G4INCLAllocationPool.hh.

86  {
87  clear();
88  }
Here is the call graph for this function:

Member Function Documentation

◆ clear()

template<typename T>
void G4INCL::AllocationPool< T >::clear ( void  )
inline

Definition at line 77 of file G4INCLAllocationPool.hh.

77  {
78  while(!theStack.empty()) { /* Loop checking, 10.07.2015, D.Mancusi */
79  ::operator delete(theStack.top());
80  theStack.pop();
81  }
82  }
Here is the caller graph for this function:

◆ getInstance()

template<typename T>
static AllocationPool& G4INCL::AllocationPool< T >::getInstance ( )
inlinestatic

Definition at line 57 of file G4INCLAllocationPool.hh.

57  {
58  if(!theInstance)
59  theInstance = new AllocationPool<T>;
60  return *theInstance;
61  }
static G4ThreadLocal AllocationPool * theInstance

◆ getObject()

template<typename T>
T* G4INCL::AllocationPool< T >::getObject ( )
inline

Definition at line 63 of file G4INCLAllocationPool.hh.

63  {
64  if(theStack.empty())
65  return static_cast<T*>(::operator new(sizeof(T)));
66  else {
67  T *t = theStack.top();
68  theStack.pop();
69  return t;
70  }
71  }

◆ recycleObject()

template<typename T>
void G4INCL::AllocationPool< T >::recycleObject ( T *  t)
inline

Definition at line 73 of file G4INCLAllocationPool.hh.

73  {
74  theStack.push(t);
75  }

Member Data Documentation

◆ theInstance

template<typename T>
G4ThreadLocal AllocationPool< T > * G4INCL::AllocationPool< T >::theInstance = 0
staticprotected

Definition at line 90 of file G4INCLAllocationPool.hh.

◆ theStack

template<typename T>
std::stack<T*> G4INCL::AllocationPool< T >::theStack
protected

Definition at line 92 of file G4INCLAllocationPool.hh.


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