Geant4-11
Public Member Functions | Static Private Attributes
G4TWorkspacePool< T > Class Template Reference

#include <G4TWorkspacePool.hh>

Public Member Functions

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

Static Private Attributes

static G4ThreadLocal T * fMyWorkspace = nullptr
 

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}
static G4ThreadLocal T * fMyWorkspace

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:35

References FatalException, and G4Exception().

◆ 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

◆ 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}

Field Documentation

◆ fMyWorkspace

template<typename T >
G4ThreadLocal T * G4TWorkspacePool< T >::fMyWorkspace = nullptr
staticprivate

Definition at line 78 of file G4TWorkspacePool.hh.

Referenced by G4TWorkspacePool< T >::GetWorkspace().


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