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

#include <G4PDefManager.hh>

Public Member Functions

 G4PDefManager ()
 
G4int CreateSubInstance ()
 
void NewSubInstances ()
 
void FreeSlave ()
 
G4PDefDataGetOffset ()
 
void UseWorkArea (G4PDefData *newOffset)
 
G4PDefDataFreeWorkArea ()
 

Static Public Member Functions

static G4PART_DLL G4intslavetotalspace ()
 
static G4PART_DLL G4PDefData *& offset ()
 

Detailed Description

Definition at line 83 of file G4PDefManager.hh.

Constructor & Destructor Documentation

◆ G4PDefManager()

G4PDefManager::G4PDefManager ( )

Definition at line 57 of file G4PDefManager.cc.

57 : totalobj(0)
58{
60}
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:87

Member Function Documentation

◆ CreateSubInstance()

G4int G4PDefManager::CreateSubInstance ( )

Definition at line 62 of file G4PDefManager.cc.

66{
67 G4AutoLock l(&mutex);
68 ++totalobj;
69 if (totalobj > slavetotalspace())
70 {
71 l.unlock();
73 l.lock();
74 }
75 return (totalobj - 1);
76}
static G4PART_DLL G4int & slavetotalspace()
void NewSubInstances()

Referenced by G4ParticleDefinition::SetParticleDefinitionID().

◆ FreeSlave()

void G4PDefManager::FreeSlave ( )

Definition at line 101 of file G4PDefManager.cc.

103{
104 if (offset() == nullptr) { return; }
105 free(offset());
106 offset() = nullptr;
107}
static G4PART_DLL G4PDefData *& offset()

Referenced by G4ParticleDefinition::Clean(), and G4ParticlesWorkspace::DestroyWorkspace().

◆ FreeWorkArea()

G4PDefData * G4PDefManager::FreeWorkArea ( )

Definition at line 126 of file G4PDefManager.cc.

129{
130 G4PDefData* offsetRet = offset();
131 offset() = nullptr;
132 return offsetRet;
133}

◆ GetOffset()

G4PDefData * G4PDefManager::GetOffset ( )

Definition at line 109 of file G4PDefManager.cc.

110{
111 return offset();
112}

Referenced by G4ParticlesWorkspace::G4ParticlesWorkspace().

◆ NewSubInstances()

void G4PDefManager::NewSubInstances ( )

Definition at line 78 of file G4PDefManager.cc.

82{
83 G4AutoLock l(&mutex);
84 if (slavetotalspace() >= totalobj) { return; }
85 G4int originaltotalspace = slavetotalspace();
86 slavetotalspace() = totalobj + 512;
87 offset() = (G4PDefData *) realloc(offset(),
88 slavetotalspace() * sizeof(G4PDefData));
89 if (offset() == nullptr)
90 {
91 G4Exception("G4PDefManager::NewSubInstances()",
92 "OutOfMemory", FatalException, "Cannot malloc space!");
93 }
94
95 for (G4int i = originaltotalspace; i < slavetotalspace(); ++i)
96 {
97 offset()[i].initialize();
98 }
99}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
int G4int
Definition: G4Types.hh:85
void initialize()

Referenced by CreateSubInstance(), and G4ParticlesWorkspace::InitialiseWorkspace().

◆ offset()

G4PDefData *& G4PDefManager::offset ( )
static

Definition at line 51 of file G4PDefManager.cc.

52{
53 G4ThreadLocalStatic G4PDefData* _instance = nullptr;
54 return _instance;
55}
#define G4ThreadLocalStatic
Definition: tls.hh:76

Referenced by FreeSlave(), FreeWorkArea(), GetOffset(), NewSubInstances(), and UseWorkArea().

◆ slavetotalspace()

G4int & G4PDefManager::slavetotalspace ( )
static

Definition at line 45 of file G4PDefManager.cc.

46{
47 G4ThreadLocalStatic G4int _instance = 0;
48 return _instance;
49}

Referenced by CreateSubInstance(), NewSubInstances(), and G4VUserPhysicsList::RemoveProcessManager().

◆ UseWorkArea()

void G4PDefManager::UseWorkArea ( G4PDefData newOffset)

Definition at line 114 of file G4PDefManager.cc.

116{
117 if( (offset() != nullptr) && (offset() != newOffset) )
118 {
119 G4Exception("G4PDefManager::UseWorkspace()",
120 "InvalidCondition", FatalException,
121 "Thread already has workspace - cannot use another.");
122 }
123 offset() = newOffset;
124}

Referenced by G4ParticlesWorkspace::ReleaseWorkspace(), and G4ParticlesWorkspace::UseWorkspace().


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