Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PTL::TaskAllocatorPool Class Reference

#include <TaskAllocatorPool.hh>

Public Member Functions

 TaskAllocatorPool (unsigned int n=0)
 
 ~TaskAllocatorPool ()
 
void * Alloc ()
 
void Free (void *b)
 
unsigned int Size () const
 
void Reset ()
 
int GetNoPages () const
 
unsigned int GetPageSize () const
 
void GrowPageSize (unsigned int factor)
 

Detailed Description

Definition at line 41 of file TaskAllocatorPool.hh.

Constructor & Destructor Documentation

◆ TaskAllocatorPool()

TaskAllocatorPool::TaskAllocatorPool ( unsigned int  n = 0)
explicit

Definition at line 37 of file TaskAllocatorPool.cc.

38: esize((sz < sizeof(PoolLink)) ? sizeof(PoolLink) : sz)
39, csize((sz < 1024 / 2 - 16) ? (1024 - 16) : (sz * 10 - 16))
40, chunks(nullptr)
41, head(nullptr)
42, nchunks(0)
43{}

◆ ~TaskAllocatorPool()

TaskAllocatorPool::~TaskAllocatorPool ( )

Definition at line 76 of file TaskAllocatorPool.cc.

Member Function Documentation

◆ Alloc()

void * PTL::TaskAllocatorPool::Alloc ( )
inline

Definition at line 112 of file TaskAllocatorPool.hh.

113{
114 if(head == nullptr)
115 Grow();
116 PoolLink* p = head; // return first element
117 head = p->next;
118 return p;
119}

◆ Free()

void PTL::TaskAllocatorPool::Free ( void *  b)
inline

Definition at line 126 of file TaskAllocatorPool.hh.

127{
128 PoolLink* p = static_cast<PoolLink*>(b);
129 p->next = head; // put b back as first element
130 head = p;
131}

◆ GetNoPages()

int PTL::TaskAllocatorPool::GetNoPages ( ) const
inline

Definition at line 148 of file TaskAllocatorPool.hh.

149{
150 return nchunks;
151}

◆ GetPageSize()

unsigned int PTL::TaskAllocatorPool::GetPageSize ( ) const
inline

Definition at line 158 of file TaskAllocatorPool.hh.

159{
160 return csize;
161}

◆ GrowPageSize()

void PTL::TaskAllocatorPool::GrowPageSize ( unsigned int  factor)
inline

Definition at line 168 of file TaskAllocatorPool.hh.

169{
170 csize = (sz) ? sz * csize : csize;
171}

◆ Reset()

void TaskAllocatorPool::Reset ( )

Definition at line 83 of file TaskAllocatorPool.cc.

84{
85 // Free all chunks
86 //
87 PoolChunk* n = chunks;
88 PoolChunk* p = nullptr;
89 while(n)
90 {
91 p = n;
92 n = n->next;
93 delete p;
94 }
95 head = nullptr;
96 chunks = nullptr;
97 nchunks = 0;
98}

Referenced by ~TaskAllocatorPool().

◆ Size()

unsigned int PTL::TaskAllocatorPool::Size ( ) const
inline

Definition at line 138 of file TaskAllocatorPool.hh.

139{
140 return nchunks * csize;
141}

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