Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NavigationHistoryPool Class Reference

G4NavigationHistoryPool is a thread-local pool for navigation history levels collections being allocated by G4NavigationHistory. It allows for reuse of the vectors allocated according to lifetime of G4NavigationHistory objects. More...

#include <G4NavigationHistoryPool.hh>

Public Member Functions

 ~G4NavigationHistoryPool ()
std::vector< G4NavigationLevel > * GetNewLevels ()
std::vector< G4NavigationLevel > * GetLevels ()
void DeRegister (std::vector< G4NavigationLevel > *pLevels)
void Clean ()
void Print () const

Static Public Member Functions

static G4NavigationHistoryPoolGetInstance ()

Detailed Description

G4NavigationHistoryPool is a thread-local pool for navigation history levels collections being allocated by G4NavigationHistory. It allows for reuse of the vectors allocated according to lifetime of G4NavigationHistory objects.

Definition at line 50 of file G4NavigationHistoryPool.hh.

Constructor & Destructor Documentation

◆ ~G4NavigationHistoryPool()

G4NavigationHistoryPool::~G4NavigationHistoryPool ( )

Destructor: takes care to delete the allocated levels.

Definition at line 57 of file G4NavigationHistoryPool.cc.

58{
59 Clean(); fgInstance = nullptr;
60}

Member Function Documentation

◆ Clean()

void G4NavigationHistoryPool::Clean ( )

Deletes all levels stored in the pool.

Definition at line 66 of file G4NavigationHistoryPool.cc.

67{
68 for(auto & i : fPool)
69 {
70 delete i;
71 }
72 fPool.clear();
73 fFree.clear();
74}

Referenced by ~G4NavigationHistoryPool().

◆ DeRegister()

void G4NavigationHistoryPool::DeRegister ( std::vector< G4NavigationLevel > * pLevels)
inline

Deactivates the levels collection in pool.

Definition at line 129 of file G4NavigationHistoryPool.hh.

131{
132 fFree.push_back(pLevels);
133}

Referenced by G4NavigationHistory::~G4NavigationHistory().

◆ GetInstance()

G4NavigationHistoryPool * G4NavigationHistoryPool::GetInstance ( )
static

Returns the unique instance of G4NavigationHistoryPool.

Definition at line 108 of file G4NavigationHistoryPool.cc.

109{
110 if (fgInstance == nullptr)
111 {
112 fgInstance = new G4NavigationHistoryPool;
113 }
114 return fgInstance;
115}

Referenced by G4NavigationHistory::G4NavigationHistory(), G4NavigationHistory::G4NavigationHistory(), G4NavigationHistory::~G4NavigationHistory(), and G4RunManagerKernel::~G4RunManagerKernel().

◆ GetLevels()

std::vector< G4NavigationLevel > * G4NavigationHistoryPool::GetLevels ( )
inline

Returns the pointer of the first available collection of levels If none are available (i.e. empty free vector) allocates the collection.

Definition at line 152 of file G4NavigationHistoryPool.hh.

153{
154 std::vector<G4NavigationLevel> * levels = nullptr;
155
156 if (!fFree.empty())
157 {
158 levels = fFree.back();
159 fFree.pop_back();
160 }
161 else
162 {
163 levels = GetNewLevels();
164 }
165
166 return levels;
167}
std::vector< G4NavigationLevel > * GetNewLevels()

Referenced by G4NavigationHistory::G4NavigationHistory(), and G4NavigationHistory::G4NavigationHistory().

◆ GetNewLevels()

std::vector< G4NavigationLevel > * G4NavigationHistoryPool::GetNewLevels ( )
inline

Returns the pointer to a new collection of levels being allocated.

Definition at line 139 of file G4NavigationHistoryPool.hh.

140{
141 auto aLevelVec = new std::vector<G4NavigationLevel>(kHistoryMax);
142 Register(aLevelVec);
143
144 return aLevelVec;
145}

Referenced by GetLevels().

◆ Print()

void G4NavigationHistoryPool::Print ( ) const

Prints the number of entries.

Definition at line 80 of file G4NavigationHistoryPool.cc.

81{
82#ifdef G4VERBOSE
83 G4cout << "Total navigation history collections cleaned: "
84 << fPool.size() << G4endl;
85#endif
86}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

Referenced by G4RunManagerKernel::~G4RunManagerKernel().


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