Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCL::AllocationPool< T > Class Template Reference

#include <G4INCLAllocationPool.hh>

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 57 of file G4INCLAllocationPool.hh.

Constructor & Destructor Documentation

◆ AllocationPool()

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

Definition at line 87 of file G4INCLAllocationPool.hh.

87{}

◆ ~AllocationPool()

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

Definition at line 88 of file G4INCLAllocationPool.hh.

88 {
89 clear();
90 }

Member Function Documentation

◆ clear()

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 }

Referenced by G4INCL::AllocationPool< T >::~AllocationPool().

◆ getInstance()

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

Definition at line 59 of file G4INCLAllocationPool.hh.

59 {
60 if(!theInstance)
62 return *theInstance;
63 }
static G4ThreadLocal AllocationPool * theInstance

◆ getObject()

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 }

◆ recycleObject()

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

◆ theInstance

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

Definition at line 92 of file G4INCLAllocationPool.hh.

Referenced by G4INCL::AllocationPool< T >::getInstance().

◆ theStack

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

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