ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
CxxUtils::pointer_list< NELT >::allocator Class Reference

Allocator for pointer_list, specialized for NELT. More...

#include <pointer_list.h>

Inheritance diagram for CxxUtils::pointer_list< NELT >::allocator:
Collaboration diagram for CxxUtils::pointer_list< NELT >::allocator:

Public Member Functions

 allocator (size_t nblock=100)
 Constructor. More...
 
list_blockallocate ()
 Allocate a new block. More...
 
size_t nelt () const
 Return the number of pointers per block (excluding the end-pointer). More...
 
size_t nchunks () const
 Return the current number of allocated chunks. More...
 
bool at_end (const void *p) const
 Test if P is pointing at the end-pointer of a block. More...
 

Static Public Member Functions

static bool at_end_static (const void *p)
 Test if P is pointing at the end-pointer of a block. More...
 

Static Public Attributes

static const unsigned long END_OFFS = NELT * sizeof(value_type)
 Verify that NELT is one less than a power of two. More...
 
static const unsigned long END_MASK = END_OFFS | (sizeof(value_type)-1)
 

Private Member Functions

void refill ()
 Allocate a new chunk of blocks. More...
 

Private Attributes

size_t m_nelt
 Number of elements per block (excluding the end-pointer). More...
 
size_t m_nblock
 Number of blocks per chunk. More...
 
chunkm_chunks
 Most recent chunk allocated. More...
 
size_t m_nthis
 Number of blocks allocated so far from that chunk. More...
 
size_t m_nchunks
 Current number of allocated chunks. More...
 
unsigned long m_end_mask
 Mask for testing for an end pointer. More...
 
unsigned long m_end_offs
 Offset for testing for an end pointer. More...
 

Detailed Description

template<size_t NELT = 15>
class CxxUtils::pointer_list< NELT >::allocator

Allocator for pointer_list, specialized for NELT.

The purpose for thsi is to be able to have the static at_end_static function, which we can call from an iterator.

Definition at line 254 of file pointer_list.h.

Constructor & Destructor Documentation

◆ allocator()

template<size_t NELT = 15>
CxxUtils::pointer_list< NELT >::allocator::allocator ( size_t  nblock = 100)

Constructor.

Parameters
nblockNumber of blocks to allocate per chunk.

Member Function Documentation

◆ allocate()

list_block* CxxUtils::pointer_list_base::allocator::allocate ( )
inherited

Allocate a new block.

◆ at_end()

bool CxxUtils::pointer_list_base::allocator::at_end ( const void *  p) const
inherited

Test if P is pointing at the end-pointer of a block.

◆ at_end_static()

template<size_t NELT = 15>
static bool CxxUtils::pointer_list< NELT >::allocator::at_end_static ( const void *  p)
static

Test if P is pointing at the end-pointer of a block.

◆ nchunks()

size_t CxxUtils::pointer_list_base::allocator::nchunks ( ) const
inherited

Return the current number of allocated chunks.

◆ nelt()

size_t CxxUtils::pointer_list_base::allocator::nelt ( ) const
inherited

Return the number of pointers per block (excluding the end-pointer).

◆ refill()

void CxxUtils::pointer_list_base::allocator::refill ( )
privateinherited

Allocate a new chunk of blocks.

Definition at line 62 of file pointer_list.cxx.

63 {
64  char* p = new char
65  [(sizeof(chunk) + m_nblock*list_block::size(m_nelt)) +
67  chunk* ch = reinterpret_cast<chunk*> (p);
68 
69  // Align.
70  unsigned long pp = reinterpret_cast<unsigned long> (ch+1);
71  pp = (pp + m_end_mask) & ~m_end_mask;
72  ch->m_blocks = reinterpret_cast<list_block*> (pp);
73 
74  ch->m_next = m_chunks;
75  m_chunks = ch;
76  ++m_nchunks;
77 
78  // No blocks allocated so far from this chunk.
79  m_nthis = 0;
80 }

Member Data Documentation

◆ END_MASK

template<size_t NELT = 15>
const unsigned long CxxUtils::pointer_list< NELT >::allocator::END_MASK = END_OFFS | (sizeof(value_type)-1)
static

Definition at line 263 of file pointer_list.h.

◆ END_OFFS

template<size_t NELT = 15>
const unsigned long CxxUtils::pointer_list< NELT >::allocator::END_OFFS = NELT * sizeof(value_type)
static

Verify that NELT is one less than a power of two.

Constants to use to test if we're at the end of a block.

Definition at line 262 of file pointer_list.h.

◆ m_chunks

chunk* CxxUtils::pointer_list_base::allocator::m_chunks
privateinherited

Most recent chunk allocated.

Definition at line 149 of file pointer_list.h.

◆ m_end_mask

unsigned long CxxUtils::pointer_list_base::allocator::m_end_mask
privateinherited

Mask for testing for an end pointer.

Definition at line 158 of file pointer_list.h.

◆ m_end_offs

unsigned long CxxUtils::pointer_list_base::allocator::m_end_offs
privateinherited

Offset for testing for an end pointer.

Definition at line 161 of file pointer_list.h.

◆ m_nblock

size_t CxxUtils::pointer_list_base::allocator::m_nblock
privateinherited

Number of blocks per chunk.

Definition at line 146 of file pointer_list.h.

◆ m_nchunks

size_t CxxUtils::pointer_list_base::allocator::m_nchunks
privateinherited

Current number of allocated chunks.

Definition at line 155 of file pointer_list.h.

◆ m_nelt

size_t CxxUtils::pointer_list_base::allocator::m_nelt
privateinherited

Number of elements per block (excluding the end-pointer).

Definition at line 143 of file pointer_list.h.

◆ m_nthis

size_t CxxUtils::pointer_list_base::allocator::m_nthis
privateinherited

Number of blocks allocated so far from that chunk.

Definition at line 152 of file pointer_list.h.


The documentation for this class was generated from the following file:
CxxUtils::pointer_list_base::allocator::m_nelt
size_t m_nelt
Number of elements per block (excluding the end-pointer).
Definition: pointer_list.h:143
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CxxUtils::pointer_list_base::allocator::m_end_mask
unsigned long m_end_mask
Mask for testing for an end pointer.
Definition: pointer_list.h:158
CxxUtils::pointer_list_base::allocator::m_nblock
size_t m_nblock
Number of blocks per chunk.
Definition: pointer_list.h:146
CxxUtils::pointer_list_base::allocator::m_chunks
chunk * m_chunks
Most recent chunk allocated.
Definition: pointer_list.h:149
CxxUtils::pointer_list_base::allocator::m_nchunks
size_t m_nchunks
Current number of allocated chunks.
Definition: pointer_list.h:155
CxxUtils::pointer_list_base::allocator::m_nthis
size_t m_nthis
Number of blocks allocated so far from that chunk.
Definition: pointer_list.h:152
CxxUtils::pointer_list_base::list_block::size
static size_t size(size_t nelt)
Size in bytes of a block holding nelt elements (excluding the end-pointer).