Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
AllocationPool
theInstance = 0
 

Detailed Description

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

Definition at line 57 of file G4INCLAllocationPool.hh.

Constructor & Destructor Documentation

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

Definition at line 87 of file G4INCLAllocationPool.hh.

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

Definition at line 88 of file G4INCLAllocationPool.hh.

88  {
89  clear();
90  }

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 79 of file G4INCLAllocationPool.hh.

79  {
80  while(!theStack.empty()) { /* Loop checking, 10.07.2015, D.Mancusi */
81  ::operator delete(theStack.top());
82  theStack.pop();
83  }
84  }

Here is the caller graph for this function:

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

Definition at line 59 of file G4INCLAllocationPool.hh.

59  {
60  if(!theInstance)
61  theInstance = new AllocationPool<T>;
62  return *theInstance;
63  }
static G4ThreadLocal AllocationPool * theInstance
template<typename T>
T* G4INCL::AllocationPool< T >::getObject ( )
inline

Definition at line 65 of file G4INCLAllocationPool.hh.

65  {
66  if(theStack.empty())
67  return static_cast<T*>(::operator new(sizeof(T)));
68  else {
69  T *t = theStack.top();
70  theStack.pop();
71  return t;
72  }
73  }
template<typename T>
void G4INCL::AllocationPool< T >::recycleObject ( T *  t)
inline

Definition at line 75 of file G4INCLAllocationPool.hh.

75  {
76  theStack.push(t);
77  }

Member Data Documentation

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

Definition at line 92 of file G4INCLAllocationPool.hh.

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

Definition at line 94 of file G4INCLAllocationPool.hh.


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