Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Attributes
G4PDefSplitter< T > Class Template Reference

#include <G4PDefSplitter.hh>

Public Member Functions

 G4PDefSplitter ()
 
G4int CreateSubInstance ()
 
void NewSubInstances ()
 
void FreeSlave ()
 

Static Public Attributes

static G4PART_DLL
G4ThreadLocal G4int 
slavetotalspace = 0
 
static G4PART_DLL G4ThreadLocal T * offset = 0
 

Detailed Description

template<class T>
class G4PDefSplitter< T >

Definition at line 52 of file G4PDefSplitter.hh.

Constructor & Destructor Documentation

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

Definition at line 56 of file G4PDefSplitter.hh.

56 : totalobj(0) {}

Member Function Documentation

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

Definition at line 58 of file G4PDefSplitter.hh.

References G4PDefSplitter< T >::NewSubInstances(), and G4PDefSplitter< T >::slavetotalspace.

Referenced by G4ParticleDefinition::SetParticleDefinitionID().

62  {
63  totalobj++;
64  if (totalobj > slavetotalspace) { NewSubInstances(); }
65  return (totalobj - 1);
66  }
static G4PART_DLL G4ThreadLocal G4int slavetotalspace
void NewSubInstances()
template<class T >
void G4PDefSplitter< T >::FreeSlave ( )
inline

Definition at line 90 of file G4PDefSplitter.hh.

References free(), and G4PDefSplitter< T >::offset.

92  {
93  if (!offset) { return; }
94  free(offset);
95  offset = 0;
96  }
void free(void *__ptr)
Definition: hjmalloc.cc:140
static G4PART_DLL G4ThreadLocal T * offset
template<class T >
void G4PDefSplitter< T >::NewSubInstances ( )
inline

Definition at line 68 of file G4PDefSplitter.hh.

References FatalException, G4Exception(), G4PDefSplitter< T >::offset, realloc(), and G4PDefSplitter< T >::slavetotalspace.

Referenced by G4PDefSplitter< T >::CreateSubInstance().

72  {
73  if (slavetotalspace >= totalobj) { return; }
74  G4int originaltotalspace = slavetotalspace;
75  slavetotalspace = totalobj + 512;
76  offset = (T *) realloc(offset, slavetotalspace * sizeof(T));
77 
78  if (offset == 0)
79  {
80  G4Exception("G4PDefSplitter::NewSubInstances()",
81  "OutOfMemory", FatalException, "Cannot malloc space!");
82  }
83 
84  for (G4int i = originaltotalspace; i < slavetotalspace; i++)
85  {
86  offset[i].initialize();
87  }
88  }
int G4int
Definition: G4Types.hh:78
static G4PART_DLL G4ThreadLocal T * offset
static G4PART_DLL G4ThreadLocal G4int slavetotalspace
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void * realloc(void *__ptr, size_t __size)
Definition: hjmalloc.cc:103

Field Documentation

template<class T >
G4ThreadLocal G4PDefData * G4PDefSplitter< G4PDefData >::offset = 0
static
template<class T >
G4ThreadLocal G4int G4PDefSplitter< G4PDefData >::slavetotalspace = 0
static

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