ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
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. More...
 
 ~ArenaSharedHeapSTLHeader ()
 Destructor. More...
 
void maybe_delete (const void *a)
 Call this when an allocator is being deleted. More...
 
ArenaAllocatorBase::Stats totstats () const
 Return allocator statistics summed over all our owned allocators. More...
 
template<class T >
ArenaHeapAllocatorget_pool ()
 Return the heap allocator for type T. More...
 
void update_owner (const void *old_owner, const void *new_owner)
 Update the owner of this object. More...
 
void report (std::ostream &os) const
 Generate printable report for all contained allocators. More...
 
void protect ()
 Write-protect the memory managed by these allocators. More...
 
void unprotect ()
 Write-enable the memory managed by these allocators. More...
 

Static Public Member Functions

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

Static Private Member Functions

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

Private Attributes

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

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 90 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 }

◆ ~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 }

Member Function Documentation

◆ get_index()

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

Return the allocator index to use for type T.

◆ get_name()

template<class T >
static 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 }

◆ 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 189 of file ArenaSharedHeapSTLAllocator.h.

◆ m_nblock

size_t SG::ArenaSharedHeapSTLHeader::m_nblock
private

Saved value for nblock parameter.

Definition at line 186 of file ArenaSharedHeapSTLAllocator.h.

◆ m_owner

const void* SG::ArenaSharedHeapSTLHeader::m_owner
private

Address of the allocator that created this header.

Definition at line 183 of file ArenaSharedHeapSTLAllocator.h.


The documentation for this class was generated from the following files:
SG::ArenaSharedHeapSTLHeader::m_owner
const void * m_owner
Address of the allocator that created this header.
Definition: ArenaSharedHeapSTLAllocator.h:183
fitman.sz
sz
Definition: fitman.py:527
trigbs_dumpHLTContentInBS.stats
stats
Definition: trigbs_dumpHLTContentInBS.py:91
lumiFormat.i
int i
Definition: lumiFormat.py:92
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::ArenaSharedHeapSTLHeader::m_allocators
std::vector< ArenaHeapAllocator * > m_allocators
List of allocators.
Definition: ArenaSharedHeapSTLAllocator.h:189
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::ArenaSharedHeapSTLHeader::m_nblock
size_t m_nblock
Saved value for nblock parameter.
Definition: ArenaSharedHeapSTLAllocator.h:186