Geant4 10.7.0
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 81 of file G4PDefManager.hh.

Constructor & Destructor Documentation

◆ G4PDefManager()

G4PDefManager::G4PDefManager ( )

Definition at line 56 of file G4PDefManager.cc.

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

Member Function Documentation

◆ CreateSubInstance()

G4int G4PDefManager::CreateSubInstance ( )

Definition at line 61 of file G4PDefManager.cc.

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

Referenced by G4ParticleDefinition::SetParticleDefinitionID().

◆ FreeSlave()

void G4PDefManager::FreeSlave ( )

Definition at line 100 of file G4PDefManager.cc.

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

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

◆ FreeWorkArea()

G4PDefData * G4PDefManager::FreeWorkArea ( )

Definition at line 125 of file G4PDefManager.cc.

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

◆ GetOffset()

G4PDefData * G4PDefManager::GetOffset ( )

Definition at line 108 of file G4PDefManager.cc.

109{
110 return offset();
111}

Referenced by G4ParticlesWorkspace::G4ParticlesWorkspace().

◆ NewSubInstances()

void G4PDefManager::NewSubInstances ( )

Definition at line 77 of file G4PDefManager.cc.

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

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

◆ offset()

G4PDefData *& G4PDefManager::offset ( )
static

Definition at line 50 of file G4PDefManager.cc.

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

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

◆ slavetotalspace()

G4int & G4PDefManager::slavetotalspace ( )
static

Definition at line 44 of file G4PDefManager.cc.

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

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

◆ UseWorkArea()

void G4PDefManager::UseWorkArea ( G4PDefData newOffset)

Definition at line 113 of file G4PDefManager.cc.

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

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


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