Geant4 11.2.2
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 82 of file G4PDefManager.hh.

Constructor & Destructor Documentation

◆ G4PDefManager()

G4PDefManager::G4PDefManager ( )

Definition at line 59 of file G4PDefManager.cc.

60{
62}
#define G4MUTEXINIT(mutex)

Member Function Documentation

◆ CreateSubInstance()

G4int G4PDefManager::CreateSubInstance ( )

Definition at line 64 of file G4PDefManager.cc.

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

Referenced by G4ParticleDefinition::SetParticleDefinitionID().

◆ FreeSlave()

void G4PDefManager::FreeSlave ( )

Definition at line 102 of file G4PDefManager.cc.

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

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

◆ FreeWorkArea()

G4PDefData * G4PDefManager::FreeWorkArea ( )

Definition at line 128 of file G4PDefManager.cc.

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

◆ GetOffset()

G4PDefData * G4PDefManager::GetOffset ( )

Definition at line 111 of file G4PDefManager.cc.

112{
113 return offset();
114}

Referenced by G4ParticlesWorkspace::G4ParticlesWorkspace().

◆ NewSubInstances()

void G4PDefManager::NewSubInstances ( )

Definition at line 79 of file G4PDefManager.cc.

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

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

◆ offset()

G4PDefData *& G4PDefManager::offset ( )
static

Definition at line 53 of file G4PDefManager.cc.

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

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

◆ slavetotalspace()

G4int & G4PDefManager::slavetotalspace ( )
static

Definition at line 47 of file G4PDefManager.cc.

48{
49 G4ThreadLocalStatic G4int _instance = 0;
50 return _instance;
51}

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

◆ UseWorkArea()

void G4PDefManager::UseWorkArea ( G4PDefData * newOffset)

Definition at line 117 of file G4PDefManager.cc.

118{
119 if ((offset() != nullptr) && (offset() != newOffset)) {
120 G4Exception("G4PDefManager::UseWorkspace()", "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: