Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TWorkspacePool< T > Class Template Reference

#include <G4TWorkspacePool.hh>

Public Member Functions

T * CreateWorkspace ()
 
void CreateAndUseWorkspace ()
 
T * FindOrCreateWorkspace ()
 
T * GetWorkspace ()
 
void Recycle (T *myWrkSpace)
 
void CleanUpAndDestroyAllWorkspaces ()
 
 G4TWorkspacePool ()
 
 ~G4TWorkspacePool ()
 

Detailed Description

template<class T>
class G4TWorkspacePool< T >

Definition at line 50 of file G4TWorkspacePool.hh.

Constructor & Destructor Documentation

◆ G4TWorkspacePool()

template<class T >
G4TWorkspacePool< T >::G4TWorkspacePool ( )
inline

Definition at line 74 of file G4TWorkspacePool.hh.

74{}

◆ ~G4TWorkspacePool()

template<class T >
G4TWorkspacePool< T >::~G4TWorkspacePool ( )
inline

Definition at line 75 of file G4TWorkspacePool.hh.

75{}

Member Function Documentation

◆ CleanUpAndDestroyAllWorkspaces()

template<class T >
void G4TWorkspacePool< T >::CleanUpAndDestroyAllWorkspaces
inline

Definition at line 144 of file G4TWorkspacePool.hh.

145{
146 if(fMyWorkspace != nullptr)
147 {
148 fMyWorkspace->DestroyWorkspace();
149 delete fMyWorkspace;
150 fMyWorkspace = nullptr;
151 }
152}

Referenced by G4WorkerThread::DestroyGeometryAndPhysicsVector().

◆ CreateAndUseWorkspace()

template<class T >
void G4TWorkspacePool< T >::CreateAndUseWorkspace
inline

Definition at line 117 of file G4TWorkspacePool.hh.

118{
119 (this->CreateWorkspace())->UseWorkspace();
120}

Referenced by G4WorkerThread::BuildGeometryAndPhysicsVector().

◆ CreateWorkspace()

template<class T >
T * G4TWorkspacePool< T >::CreateWorkspace
inline

Definition at line 90 of file G4TWorkspacePool.hh.

91{
92 T* wrk = nullptr;
93 if(fMyWorkspace == nullptr)
94 {
95 wrk = new T;
96 if(wrk == nullptr)
97 {
98 G4Exception("G4TWorspacePool<someType>::CreateWorkspace()", "MemoryError",
99 FatalException, "Failed to create workspace.");
100 }
101 else
102 {
103 fMyWorkspace = wrk;
104 }
105 }
106 else
107 {
108 G4Exception("ParticlesWorspacePool::CreateWorkspace()", "InvalidCondition",
110 "Cannot create workspace twice for the same thread.");
111 wrk = fMyWorkspace;
112 }
113 return wrk;
114}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59

◆ FindOrCreateWorkspace()

template<class T >
T * G4TWorkspacePool< T >::FindOrCreateWorkspace
inline

Definition at line 123 of file G4TWorkspacePool.hh.

124{
125 T* wrk = fMyWorkspace;
126 if(wrk == nullptr)
127 {
128 wrk = this->CreateWorkspace();
129 }
130 wrk->UseWorkspace();
131
132 fMyWorkspace = wrk; // assign it for use by this thread.
133 return wrk;
134}

◆ GetWorkspace()

template<class T >
T * G4TWorkspacePool< T >::GetWorkspace ( )
inline

Definition at line 65 of file G4TWorkspacePool.hh.

65{ return fMyWorkspace; }

Referenced by G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster().

◆ Recycle()

template<class T >
void G4TWorkspacePool< T >::Recycle ( T *  myWrkSpace)
inline

Definition at line 137 of file G4TWorkspacePool.hh.

138{
139 myWrkSpace->ReleaseWorkspace();
140 delete myWrkSpace;
141}

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