Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4GeomSplitter< T > Class Template Reference

#include <G4GeomSplitter.hh>

Public Member Functions

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

Static Public Attributes

static G4GEOM_DLL G4ThreadLocal T * offset = 0
 

Detailed Description

template<class T>
class G4GeomSplitter< T >

Definition at line 51 of file G4GeomSplitter.hh.

Constructor & Destructor Documentation

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

Definition at line 55 of file G4GeomSplitter.hh.

56  : totalobj(0), totalspace(0), sharedOffset(0)
57  {
59  }
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:177

Member Function Documentation

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

Definition at line 81 of file G4GeomSplitter.hh.

82  {
83  G4AutoLock l(&mutex);
84  memcpy(offset, sharedOffset, totalspace * sizeof(T));
85  }
static G4GEOM_DLL G4ThreadLocal T * offset

Here is the caller graph for this function:

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

Definition at line 61 of file G4GeomSplitter.hh.

64  {
65  G4AutoLock l(&mutex);
66  totalobj++;
67  if (totalobj > totalspace)
68  {
69  totalspace=totalspace + 512;
70  offset = (T *) realloc(offset, totalspace * sizeof(T));
71  if (offset == 0)
72  {
73  G4Exception("G4GeomSPlitter::CreateSubInstance()",
74  "OutOfMemory", FatalException, "Cannot malloc space!");
75  }
76  sharedOffset = offset;
77  }
78  return (totalobj - 1);
79  }
static G4GEOM_DLL G4ThreadLocal T * 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:

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

Definition at line 180 of file G4GeomSplitter.hh.

181  {
182 
183  }
template<class T >
void G4GeomSplitter< T >::FreeSlave ( )
inline

Definition at line 141 of file G4GeomSplitter.hh.

143  {
144  if (!offset) { return; }
145  free( offset );
146  offset = 0;
147  }
static G4GEOM_DLL G4ThreadLocal T * offset

Here is the caller graph for this function:

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

Definition at line 168 of file G4GeomSplitter.hh.

169  {
170  // Detach this thread from this Location
171  // The object which calls this method is responsible for it.
172  //
173  T* offsetRet= offset;
174 
175  offset= 0;
176 
177  return offsetRet;
178  }
static G4GEOM_DLL G4ThreadLocal T * offset
template<class T >
T* G4GeomSplitter< T >::GetOffset ( )
inline

Definition at line 152 of file G4GeomSplitter.hh.

152 { return offset; }
static G4GEOM_DLL G4ThreadLocal T * offset

Here is the caller graph for this function:

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

Definition at line 87 of file G4GeomSplitter.hh.

90  {
91  G4AutoLock l(&mutex);
92  if (offset) { return; }
93  offset = (T *) realloc(offset, totalspace * sizeof(T));
94  if (offset == 0)
95  {
96  G4Exception("G4GeomSplitter::SlaveCopySubInstanceArray()",
97  "OutOfMemory", FatalException, "Cannot malloc space!");
98  }
99  l.unlock();
101  }
void CopyMasterContents()
static G4GEOM_DLL G4ThreadLocal T * 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:

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

Definition at line 103 of file G4GeomSplitter.hh.

107  {
108  G4AutoLock l(&mutex);
109  if (offset) { return; }
110  offset = (T *) realloc(offset, totalspace * sizeof(T));
111 
112  if (offset == 0)
113  {
114  G4Exception("G4GeomSplitter::SlaveInitializeSubInstance()",
115  "OutOfMemory", FatalException, "Cannot malloc space!");
116  }
117 
118  for (G4int i = 0 ; i < totalspace ; i++)
119  {
120  offset[i].initialize();
121  }
122  }
static G4GEOM_DLL G4ThreadLocal T * offset
int G4int
Definition: G4Types.hh:78
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:

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

Definition at line 124 of file G4GeomSplitter.hh.

128  {
129  G4AutoLock l(&mutex);
130  if (!offset)
131  {
133  G4Exception("G4GeomSPlitter::SlaveReCopySubInstance()",
134  "MissingInitialisation", JustWarning,
135  "Must be called after Initialisation or first Copy.");
136  }
137  l.unlock();
139  }
void CopyMasterContents()
static G4GEOM_DLL G4ThreadLocal T * offset
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SlaveInitializeSubInstance()

Here is the call graph for this function:

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

Definition at line 154 of file G4GeomSplitter.hh.

155  {
156  // Use recycled work area - which was created previously
157  if( offset && offset!=newOffset )
158  {
159  G4Exception("G4GeomSplitter::UseWorkspace()",
160  "TwoWorkspaces", FatalException,
161  "Thread already has workspace - cannot use another.");
162  }
163  offset= newOffset;
164  // totalobj= numObjects;
165  // totalspace= numSpace;
166  }
static G4GEOM_DLL G4ThreadLocal T * 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

template<class T >
G4ThreadLocal T * G4GeomSplitter< T >::offset = 0
static

Definition at line 187 of file G4GeomSplitter.hh.


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