Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4PDefManager Class Reference

#include <G4PDefManager.hh>

Collaboration diagram for G4PDefManager:

Public Member Functions

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

Public Attributes

G4PART_DLL G4ThreadLocalStatic
G4int 
slavetotalspace =0
 
G4PART_DLL G4ThreadLocalStatic
G4PDefData
offset =0
 

Detailed Description

Definition at line 87 of file G4PDefManager.hh.

Constructor & Destructor Documentation

G4PDefManager::G4PDefManager ( )

Definition at line 59 of file G4PDefManager.cc.

59  : totalobj(0)
60 {
62 }
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:177

Member Function Documentation

G4int G4PDefManager::CreateSubInstance ( )

Definition at line 64 of file G4PDefManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4PDefManager::FreeSlave ( )

Definition at line 103 of file G4PDefManager.cc.

105 {
106  if (!offset) { return; }
107  free(offset);
108  offset = 0;
109 }
G4PART_DLL G4ThreadLocalStatic G4PDefData * offset

Here is the caller graph for this function:

G4PDefData * G4PDefManager::FreeWorkArea ( )

Definition at line 131 of file G4PDefManager.cc.

132 {
133  // Detach this thread from this Location
134  // The object which calls this method is responsible for it.
135  //
136  G4PDefData* offsetRet= offset;
137 
138  offset= 0;
139 
140  return offsetRet;
141 }
G4PART_DLL G4ThreadLocalStatic G4PDefData * offset
G4PDefData * G4PDefManager::GetOffset ( )

Definition at line 112 of file G4PDefManager.cc.

113 {
114  return offset;
115 }
G4PART_DLL G4ThreadLocalStatic G4PDefData * offset

Here is the caller graph for this function:

void G4PDefManager::NewSubInstances ( )

Definition at line 80 of file G4PDefManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4PDefManager::UseWorkArea ( G4PDefData newOffset)

Definition at line 117 of file G4PDefManager.cc.

118 {
119  // Use recycled work area - which was created previously
120  if( offset && offset!=newOffset )
121  {
122  G4Exception("G4PDefManager::UseWorkspace()",
123  "TwoWorkspaces", FatalException,
124  "Thread already has workspace - cannot use another.");
125  }
126  offset= newOffset;
127  // totalobj= numObjects;
128  // totalspace= numSpace;
129 }
G4PART_DLL G4ThreadLocalStatic G4PDefData * offset
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

G4ThreadLocal G4PDefData * G4PDefManager::offset =0

Definition at line 116 of file G4PDefManager.hh.

G4ThreadLocal G4int G4PDefManager::slavetotalspace =0

Definition at line 115 of file G4PDefManager.hh.


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