Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GeomSplitter< T > Class Template Reference

#include <G4GeomSplitter.hh>

Public Member Functions

 G4GeomSplitter ()
 
T * Reallocate (G4int size)
 
G4int CreateSubInstance ()
 
void CopyMasterContents ()
 
void SlaveCopySubInstanceArray ()
 
void SlaveInitializeSubInstance ()
 
void SlaveReCopySubInstanceArray ()
 
void FreeSlave ()
 
T * GetOffset ()
 
void UseWorkArea (T *newOffset)
 
T * FreeWorkArea ()
 

Static Public Attributes

static G4GEOM_DLL G4ThreadLocal T * offset = nullptr
 

Detailed Description

template<class T>
class G4GeomSplitter< T >

Definition at line 44 of file G4GeomSplitter.hh.

Constructor & Destructor Documentation

◆ G4GeomSplitter()

template<class T >
G4GeomSplitter< T >::G4GeomSplitter ( )
inline

Definition at line 48 of file G4GeomSplitter.hh.

49 : totalobj(0), totalspace(0), sharedOffset(nullptr)
50 {
52 }
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:87

Member Function Documentation

◆ CopyMasterContents()

template<class T >
void G4GeomSplitter< T >::CopyMasterContents ( )
inline

Definition at line 79 of file G4GeomSplitter.hh.

80 {
81 G4AutoLock l(&mutex);
82 std::memcpy(offset, sharedOffset, totalspace * sizeof(T));
83 }
static G4GEOM_DLL G4ThreadLocal T * offset

Referenced by G4GeomSplitter< T >::SlaveCopySubInstanceArray(), and G4GeomSplitter< T >::SlaveReCopySubInstanceArray().

◆ CreateSubInstance()

template<class T >
G4int G4GeomSplitter< T >::CreateSubInstance ( )
inline

Definition at line 60 of file G4GeomSplitter.hh.

63 {
64 G4AutoLock l(&mutex);
65 ++totalobj;
66 if (totalobj > totalspace)
67 {
68 offset = Reallocate(totalspace+512);
69 if (offset == nullptr)
70 {
71 G4Exception("G4GeomSPlitter::CreateSubInstance()",
72 "OutOfMemory", FatalException, "Cannot malloc space!");
73 }
74 sharedOffset = offset;
75 }
76 return (totalobj - 1);
77 }
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
T * Reallocate(G4int size)

Referenced by G4LogicalVolume::G4LogicalVolume(), G4PolyconeSide::G4PolyconeSide(), G4PolyhedraSide::G4PolyhedraSide(), G4PVReplica::G4PVReplica(), G4Region::G4Region(), and G4VPhysicalVolume::G4VPhysicalVolume().

◆ FreeSlave()

template<class T >
void G4GeomSplitter< T >::FreeSlave ( )
inline

Definition at line 138 of file G4GeomSplitter.hh.

140 {
141 if (offset == nullptr) { return; }
142 std::free( offset );
143 offset = nullptr;
144 }

Referenced by G4LogicalVolume::Clean(), G4Region::Clean(), G4VPhysicalVolume::Clean(), G4SolidsWorkspace::DestroyWorkspace(), and G4GeometryWorkspace::DestroyWorkspace().

◆ FreeWorkArea()

template<class T >
T * G4GeomSplitter< T >::FreeWorkArea ( )
inline

Definition at line 162 of file G4GeomSplitter.hh.

165 {
166 T* offsetRet = offset;
167 offset = nullptr;
168 return offsetRet;
169 }

◆ GetOffset()

template<class T >
T * G4GeomSplitter< T >::GetOffset ( )
inline

◆ Reallocate()

template<class T >
T * G4GeomSplitter< T >::Reallocate ( G4int  size)
inline

Definition at line 54 of file G4GeomSplitter.hh.

55 {
56 totalspace = size;
57 return (T *) std::realloc(offset, totalspace * sizeof(T));
58 }

Referenced by G4GeomSplitter< T >::CreateSubInstance(), G4GeomSplitter< T >::SlaveCopySubInstanceArray(), and G4GeomSplitter< T >::SlaveInitializeSubInstance().

◆ SlaveCopySubInstanceArray()

template<class T >
void G4GeomSplitter< T >::SlaveCopySubInstanceArray ( )
inline

Definition at line 85 of file G4GeomSplitter.hh.

88 {
89 G4AutoLock l(&mutex);
90 if (offset != nullptr) { return; }
91 offset = Reallocate(totalspace);
92 if (offset == nullptr)
93 {
94 G4Exception("G4GeomSplitter::SlaveCopySubInstanceArray()",
95 "OutOfMemory", FatalException, "Cannot malloc space!");
96 }
97 l.unlock();
99 }
void CopyMasterContents()

Referenced by G4LogicalVolume::InitialiseWorker(), G4PVReplica::InitialiseWorker(), G4VPhysicalVolume::InitialiseWorker(), and G4GeometryWorkspace::InitialiseWorkspace().

◆ SlaveInitializeSubInstance()

template<class T >
void G4GeomSplitter< T >::SlaveInitializeSubInstance ( )
inline

Definition at line 101 of file G4GeomSplitter.hh.

105 {
106 G4AutoLock l(&mutex);
107 if (offset != nullptr) { return; }
108 offset = Reallocate(totalspace);
109
110 if (offset == nullptr)
111 {
112 G4Exception("G4GeomSplitter::SlaveInitializeSubInstance()",
113 "OutOfMemory", FatalException, "Cannot malloc space!");
114 }
115
116 for (G4int i=0 ; i<totalspace; ++i)
117 {
118 offset[i].initialize();
119 }
120 }
int G4int
Definition: G4Types.hh:85

Referenced by G4SolidsWorkspace::InitialiseWorkspace(), G4GeometryWorkspace::InitialiseWorkspace(), and G4GeomSplitter< T >::SlaveReCopySubInstanceArray().

◆ SlaveReCopySubInstanceArray()

template<class T >
void G4GeomSplitter< T >::SlaveReCopySubInstanceArray ( )
inline

Definition at line 122 of file G4GeomSplitter.hh.

127 {
128 if (offset == nullptr)
129 {
131 G4Exception("G4GeomSPlitter::SlaveReCopySubInstance()",
132 "MissingInitialisation", JustWarning,
133 "Must be called after Initialisation or first Copy.");
134 }
136 }
@ JustWarning
void SlaveInitializeSubInstance()

◆ UseWorkArea()

template<class T >
void G4GeomSplitter< T >::UseWorkArea ( T *  newOffset)
inline

Definition at line 150 of file G4GeomSplitter.hh.

152 {
153 if( (offset!=nullptr) && (offset!=newOffset) )
154 {
155 G4Exception("G4GeomSplitter::UseWorkspace()",
156 "TwoWorkspaces", FatalException,
157 "Thread already has workspace - cannot use another.");
158 }
159 offset= newOffset;
160 }

Referenced by G4SolidsWorkspace::ReleaseWorkspace(), G4GeometryWorkspace::ReleaseWorkspace(), G4SolidsWorkspace::UseWorkspace(), and G4GeometryWorkspace::UseWorkspace().

Member Data Documentation

◆ offset


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