Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Friends
G4ThreadLocalSingleton< T > Class Template Reference

#include <G4ThreadLocalSingleton.hh>

Inheritance diagram for G4ThreadLocalSingleton< T >:
G4Cache< T * >

Public Member Functions

 G4ThreadLocalSingleton ()
 
 ~G4ThreadLocalSingleton ()
 
T * Instance () const
 

Friends

void G4AutoDelete::Register (T *)
 

Detailed Description

template<class T>
class G4ThreadLocalSingleton< T >

Definition at line 108 of file G4ThreadLocalSingleton.hh.

Constructor & Destructor Documentation

template<class T >
G4ThreadLocalSingleton< T >::G4ThreadLocalSingleton ( )

Definition at line 135 of file G4ThreadLocalSingleton.hh.

References G4MUTEXINIT, and G4Cache< VALTYPE >::Put().

135  : G4Cache<T*>() {
136  G4MUTEXINIT(listm);
137  G4Cache<T*>::Put(static_cast<T*>(0));
138 }
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:160
void Put(const value_type &val) const
Definition: G4Cache.hh:257
template<class T >
G4ThreadLocalSingleton< T >::~G4ThreadLocalSingleton ( )

Definition at line 141 of file G4ThreadLocalSingleton.hh.

References JA::Clear().

141  {
142  Clear();
143 }

Member Function Documentation

template<class T >
T * G4ThreadLocalSingleton< T >::Instance ( void  ) const

Definition at line 146 of file G4ThreadLocalSingleton.hh.

References G4Cache< VALTYPE >::Get(), G4Cache< VALTYPE >::Put(), and G4AutoDelete::Register().

Referenced by G4BiasingTrackDataStore::GetInstance(), G4BiasingOperationManager::GetInstance(), and G4LossTableManager::Instance().

146  {
147  T* instance = G4Cache<T*>::Get();
148  if ( instance == static_cast<T*>(0) ) {
149  instance = new T;
150  G4Cache<T*>::Put( instance );
151  Register(instance);
152  }
153  return instance;
154  }
value_type & Get() const
Definition: G4Cache.hh:253
void Put(const value_type &val) const
Definition: G4Cache.hh:257

Friends And Related Function Documentation

template<class T>
void G4AutoDelete::Register ( T *  )
friend

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