ATLAS Offline Software
Loading...
Searching...
No Matches
SG::ArenaSharedHeapSTLHeader Class Reference

Common header class for ArenaSharedHeapSTLAllocator. More...

#include <ArenaSharedHeapSTLAllocator.h>

Collaboration diagram for SG::ArenaSharedHeapSTLHeader:

Public Member Functions

 ArenaSharedHeapSTLHeader (const void *owner, int nblock)
 Constructor.
 ~ArenaSharedHeapSTLHeader ()
 Destructor.
void maybe_delete (const void *a)
 Call this when an allocator is being deleted.
ArenaAllocatorBase::Stats totstats () const
 Return allocator statistics summed over all our owned allocators.
template<class T>
ArenaHeapAllocatorget_pool ()
 Return the heap allocator for type T.
void update_owner (const void *old_owner, const void *new_owner)
 Update the owner of this object.
void report (std::ostream &os) const
 Generate printable report for all contained allocators.
void protect ()
 Write-protect the memory managed by these allocators.
void unprotect ()
 Write-enable the memory managed by these allocators.

Static Public Member Functions

template<class T>
static std::string get_name ()
 Return the name to use for an allocator for type T.

Static Private Member Functions

template<class T>
static size_t get_index ()
 Return the allocator index to use for type T.

Private Attributes

const void * m_owner
 Address of the allocator that created this header.
size_t m_nblock
 Saved value for nblock parameter.
std::vector< ArenaHeapAllocator * > m_allocators
 List of allocators.

Detailed Description

Common header class for ArenaSharedHeapSTLAllocator.

Each ArenaSharedHeapSTLAllocator has a pointer to a Header class. When a new ASHSTLAllocator object is constructed, we make a new Header; after that, the Header pointer is copied on copy-construction. The Header remembers the address of the object that created it, so that it can be deleted when that allocator is.

The Header contains a list of ArenaHeapAllocator objects, one for each type we're allocating.

Definition at line 89 of file ArenaSharedHeapSTLAllocator.h.

Constructor & Destructor Documentation

◆ ArenaSharedHeapSTLHeader()

SG::ArenaSharedHeapSTLHeader::ArenaSharedHeapSTLHeader ( const void * owner,
int nblock )

Constructor.

Parameters
ownerAddress of the object that owns this Header.
nblockValue to set in the parameters structure for the number of elements to allocate per block.
ownerAddress of the object that owns this Header.
nblockValue to set in the parameters structure for the number of elements to allocate per block.
nameValue to use as the base for the allocator names.

Definition at line 26 of file ArenaSharedHeapSTLAllocator.cxx.

28 : m_owner (owner),
29 m_nblock (nblock)
30{
31}
const void * m_owner
Address of the allocator that created this header.
size_t m_nblock
Saved value for nblock parameter.

◆ ~ArenaSharedHeapSTLHeader()

SG::ArenaSharedHeapSTLHeader::~ArenaSharedHeapSTLHeader ( )

Destructor.

Destroy all the allocators we own.

Definition at line 39 of file ArenaSharedHeapSTLAllocator.cxx.

40{
41 size_t sz = m_allocators.size();
42 for (size_t i = 0; i < sz; i++) {
43 delete m_allocators[i];
44 }
45}
static Double_t sz
std::vector< ArenaHeapAllocator * > m_allocators
List of allocators.

Member Function Documentation

◆ get_index()

template<class T>
size_t SG::ArenaSharedHeapSTLHeader::get_index ( )
staticprivate

Return the allocator index to use for type T.

◆ get_name()

template<class T>
std::string SG::ArenaSharedHeapSTLHeader::get_name ( )
static

Return the name to use for an allocator for type T.

◆ get_pool()

template<class T>
ArenaHeapAllocator * SG::ArenaSharedHeapSTLHeader::get_pool ( )

Return the heap allocator for type T.

◆ maybe_delete()

void SG::ArenaSharedHeapSTLHeader::maybe_delete ( const void * a)

Call this when an allocator is being deleted.

Parameters
aThe address of calling allocator.

If the address matches the address we were given when we were created, this object will be destroyed.

◆ protect()

void SG::ArenaSharedHeapSTLHeader::protect ( )

Write-protect the memory managed by these allocators.

Adjust protection on the memory managed by these allocators to disallow writes.

Definition at line 82 of file ArenaSharedHeapSTLAllocator.cxx.

83{
84 for (ArenaHeapAllocator* a : m_allocators) {
85 if (a) {
86 a->protect();
87 }
88 }
89}
static Double_t a

◆ report()

void SG::ArenaSharedHeapSTLHeader::report ( std::ostream & os) const

Generate printable report for all contained allocators.

Parameters
osStream to which to write the report.

Definition at line 67 of file ArenaSharedHeapSTLAllocator.cxx.

68{
69 for (size_t i = 0; i < m_allocators.size(); i++) {
70 if (m_allocators[i])
71 m_allocators[i]->report (os);
72 }
73}

◆ totstats()

ArenaAllocatorBase::Stats SG::ArenaSharedHeapSTLHeader::totstats ( ) const

Return allocator statistics summed over all our owned allocators.

Definition at line 51 of file ArenaSharedHeapSTLAllocator.cxx.

52{
53 ArenaAllocatorBase::Stats stats;
54 size_t sz = m_allocators.size();
55 for (size_t i = 0; i < sz; i++) {
56 if (m_allocators[i])
57 stats += m_allocators[i]->stats();
58 }
59 return stats;
60}

◆ unprotect()

void SG::ArenaSharedHeapSTLHeader::unprotect ( )

Write-enable the memory managed by these allocators.

Adjust protection on the memory managed by these allocators to allow writes.

Definition at line 98 of file ArenaSharedHeapSTLAllocator.cxx.

99{
100 for (ArenaHeapAllocator* a : m_allocators) {
101 if (a) {
102 a->unprotect();
103 }
104 }
105}

◆ update_owner()

void SG::ArenaSharedHeapSTLHeader::update_owner ( const void * old_owner,
const void * new_owner )

Update the owner of this object.

Parameters
old_ownerObject giving up ownership.
new_ownerObject acquiring ownership.

If the current owner is old_owner then change the owner to new_owner.

Member Data Documentation

◆ m_allocators

std::vector<ArenaHeapAllocator*> SG::ArenaSharedHeapSTLHeader::m_allocators
private

List of allocators.

Definition at line 188 of file ArenaSharedHeapSTLAllocator.h.

◆ m_nblock

size_t SG::ArenaSharedHeapSTLHeader::m_nblock
private

Saved value for nblock parameter.

Definition at line 185 of file ArenaSharedHeapSTLAllocator.h.

◆ m_owner

const void* SG::ArenaSharedHeapSTLHeader::m_owner
private

Address of the allocator that created this header.

Definition at line 182 of file ArenaSharedHeapSTLAllocator.h.


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