Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PTL::TaskAllocatorImpl< Type > Class Template Reference

#include <TaskAllocator.hh>

+ Inheritance diagram for PTL::TaskAllocatorImpl< Type >:

Classes

struct  rebind
 

Public Types

typedef Type value_type
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef Typepointer
 
typedef const Typeconst_pointer
 
typedef Typereference
 
typedef const Typeconst_reference
 

Public Member Functions

 TaskAllocatorImpl ()
 
 ~TaskAllocatorImpl ()
 
TypeMallocSingle ()
 
void FreeSingle (Type *anElement)
 
void ResetStorage () override
 
size_t GetAllocatedSize () const override
 
int GetNoPages () const override
 
size_t GetPageSize () const override
 
void IncreasePageSize (unsigned int sz) override
 
const char * GetPoolType () const override
 
template<class U >
 TaskAllocatorImpl (const TaskAllocatorImpl< U > &right) throw ()
 
pointer address (reference r) const
 
const_pointer address (const_reference r) const
 
pointer allocate (size_type n, void *=0)
 
void deallocate (pointer p, size_type n)
 
void construct (pointer p, const Type &val)
 
void destroy (pointer p)
 
size_type max_size () const throw ()
 
- Public Member Functions inherited from PTL::TaskAllocatorBase
 TaskAllocatorBase ()
 
virtual ~TaskAllocatorBase ()
 
virtual void ResetStorage ()=0
 
virtual size_t GetAllocatedSize () const =0
 
virtual int GetNoPages () const =0
 
virtual size_t GetPageSize () const =0
 
virtual void IncreasePageSize (unsigned int sz)=0
 
virtual const char * GetPoolType () const =0
 

Public Attributes

TaskAllocatorPool mem
 

Detailed Description

template<class Type>
class PTL::TaskAllocatorImpl< Type >

Definition at line 61 of file TaskAllocator.hh.

Member Typedef Documentation

◆ const_pointer

template<class Type >
typedef const Type* PTL::TaskAllocatorImpl< Type >::const_pointer

Definition at line 101 of file TaskAllocator.hh.

◆ const_reference

template<class Type >
typedef const Type& PTL::TaskAllocatorImpl< Type >::const_reference

Definition at line 103 of file TaskAllocator.hh.

◆ difference_type

template<class Type >
typedef ptrdiff_t PTL::TaskAllocatorImpl< Type >::difference_type

Definition at line 99 of file TaskAllocator.hh.

◆ pointer

template<class Type >
typedef Type* PTL::TaskAllocatorImpl< Type >::pointer

Definition at line 100 of file TaskAllocator.hh.

◆ reference

template<class Type >
typedef Type& PTL::TaskAllocatorImpl< Type >::reference

Definition at line 102 of file TaskAllocator.hh.

◆ size_type

template<class Type >
typedef size_t PTL::TaskAllocatorImpl< Type >::size_type

Definition at line 98 of file TaskAllocator.hh.

◆ value_type

template<class Type >
typedef Type PTL::TaskAllocatorImpl< Type >::value_type

Definition at line 97 of file TaskAllocator.hh.

Constructor & Destructor Documentation

◆ TaskAllocatorImpl() [1/2]

template<class Type >
PTL::TaskAllocatorImpl< Type >::TaskAllocatorImpl

Definition at line 211 of file TaskAllocator.hh.

212: mem(sizeof(Type))
213, tname(typeid(Type).name())
214{}
TaskAllocatorPool mem
const char * name(G4int ptype)

◆ ~TaskAllocatorImpl()

Definition at line 221 of file TaskAllocator.hh.

222{}

◆ TaskAllocatorImpl() [2/2]

template<class Type >
template<class U >
PTL::TaskAllocatorImpl< Type >::TaskAllocatorImpl ( const TaskAllocatorImpl< U > &  right)
throw (
)
inline

Definition at line 106 of file TaskAllocator.hh.

107 : mem(right.mem)
108 , tname(right.name())
109 {}

Member Function Documentation

◆ address() [1/2]

template<class Type >
const_pointer PTL::TaskAllocatorImpl< Type >::address ( const_reference  r) const
inline

Definition at line 113 of file TaskAllocator.hh.

113{ return &r; }

◆ address() [2/2]

template<class Type >
pointer PTL::TaskAllocatorImpl< Type >::address ( reference  r) const
inline

Definition at line 112 of file TaskAllocator.hh.

112{ return &r; }

◆ allocate()

template<class Type >
pointer PTL::TaskAllocatorImpl< Type >::allocate ( size_type  n,
void *  = 0 
)
inline

Definition at line 116 of file TaskAllocator.hh.

117 {
118 // Allocates space for n elements of type Type, but does not initialise
119 //
120 Type* mem_alloc = 0;
121 if(n == 1)
122 mem_alloc = MallocSingle();
123 else
124 mem_alloc = static_cast<Type*>(::operator new(n * sizeof(Type)));
125 return mem_alloc;
126 }
G4ProfileType Type

◆ construct()

template<class Type >
void PTL::TaskAllocatorImpl< Type >::construct ( pointer  p,
const Type val 
)
inline

Definition at line 138 of file TaskAllocator.hh.

138{ new((void*) p) Type(val); }

◆ deallocate()

template<class Type >
void PTL::TaskAllocatorImpl< Type >::deallocate ( pointer  p,
size_type  n 
)
inline

Definition at line 127 of file TaskAllocator.hh.

128 {
129 // Deallocates n elements of type Type, but doesn't destroy
130 //
131 if(n == 1)
132 FreeSingle(p);
133 else
134 ::operator delete((void*) p);
135 return;
136 }
void FreeSingle(Type *anElement)

◆ destroy()

template<class Type >
void PTL::TaskAllocatorImpl< Type >::destroy ( pointer  p)
inline

Definition at line 140 of file TaskAllocator.hh.

140{ p->~Type(); }

◆ FreeSingle()

template<class Type >
void PTL::TaskAllocatorImpl< Type >::FreeSingle ( Type anElement)
inline

Definition at line 241 of file TaskAllocator.hh.

242{
243 mem.Free(anElement);
244 return;
245}

Referenced by PTL::TaskAllocatorImpl< Type >::deallocate(), and PTL::TaskAllocator< Type >::operator delete().

◆ GetAllocatedSize()

template<class Type >
size_t PTL::TaskAllocatorImpl< Type >::GetAllocatedSize
inlineoverridevirtual

Implements PTL::TaskAllocatorBase.

Definition at line 267 of file TaskAllocator.hh.

268{
269 return mem.Size();
270}
unsigned int Size() const

◆ GetNoPages()

template<class Type >
int PTL::TaskAllocatorImpl< Type >::GetNoPages
inlineoverridevirtual

Implements PTL::TaskAllocatorBase.

Definition at line 278 of file TaskAllocator.hh.

279{
280 return mem.GetNoPages();
281}

◆ GetPageSize()

template<class Type >
size_t PTL::TaskAllocatorImpl< Type >::GetPageSize
inlineoverridevirtual

Implements PTL::TaskAllocatorBase.

Definition at line 289 of file TaskAllocator.hh.

290{
291 return mem.GetPageSize();
292}
unsigned int GetPageSize() const

◆ GetPoolType()

template<class Type >
const char * PTL::TaskAllocatorImpl< Type >::GetPoolType
inlineoverridevirtual

Implements PTL::TaskAllocatorBase.

Definition at line 312 of file TaskAllocator.hh.

313{
314 return tname;
315}

◆ IncreasePageSize()

template<class Type >
void PTL::TaskAllocatorImpl< Type >::IncreasePageSize ( unsigned int  sz)
inlineoverridevirtual

Implements PTL::TaskAllocatorBase.

Definition at line 300 of file TaskAllocator.hh.

301{
302 ResetStorage();
303 mem.GrowPageSize(sz);
304}
void ResetStorage() override
void GrowPageSize(unsigned int factor)

◆ MallocSingle()

template<class Type >
Type * PTL::TaskAllocatorImpl< Type >::MallocSingle
inline

Definition at line 230 of file TaskAllocator.hh.

231{
232 return static_cast<Type*>(mem.Alloc());
233}

Referenced by PTL::TaskAllocatorImpl< Type >::allocate(), and PTL::TaskAllocator< Type >::operator new().

◆ max_size()

template<class Type >
size_type PTL::TaskAllocatorImpl< Type >::max_size ( ) const
throw (
)
inline

Definition at line 143 of file TaskAllocator.hh.

144 {
145 // Returns the maximum number of elements that can be allocated
146 //
147 return 2147483647 / sizeof(Type);
148 }

◆ ResetStorage()

template<class Type >
void PTL::TaskAllocatorImpl< Type >::ResetStorage
inlineoverridevirtual

Implements PTL::TaskAllocatorBase.

Definition at line 253 of file TaskAllocator.hh.

254{
255 // Clear all allocated storage and return it to the free store
256 //
257 mem.Reset();
258 return;
259}

Member Data Documentation

◆ mem

Definition at line 157 of file TaskAllocator.hh.


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