ATLAS Offline Software
|
Common functionality for block-oriented allocators. More...
#include <ArenaBlockAllocatorBase.h>
Public Types | |
typedef char * | pointer |
Type for pointers to elements. More... | |
typedef const char * | const_pointer |
And a const version of the pointer. More... | |
typedef void | func_t(pointer) |
Type of functions for constructor , etc. More... | |
Public Member Functions | |
ArenaBlockAllocatorBase (const Params ¶ms) | |
Constructor. More... | |
virtual | ~ArenaBlockAllocatorBase () |
Destructor. More... | |
ArenaBlockAllocatorBase (const ArenaBlockAllocatorBase &)=delete | |
Don't allow copy construction or assignment. More... | |
ArenaBlockAllocatorBase & | operator= (const ArenaBlockAllocatorBase &)=delete |
ArenaBlockAllocatorBase (ArenaBlockAllocatorBase &&other) | |
Move constructor. More... | |
ArenaBlockAllocatorBase & | operator= (ArenaBlockAllocatorBase &&other) |
Move assignment. More... | |
void | swap (ArenaBlockAllocatorBase &other) |
Swap. More... | |
virtual void | reserve (size_t size) override |
Set the total number of elements cached by the allocator. More... | |
virtual void | erase () override |
Free all allocated elements and release memory back to the system. More... | |
virtual Stats | stats () const override |
Return the statistics block for this allocator. More... | |
virtual const std::string & | name () const override |
Return the name of this allocator. More... | |
const Params & | params () const |
Return this Allocator's parameters. More... | |
void | protect () |
Write-protect the memory managed by this allocator. More... | |
void | unprotect () |
Write-enable the memory managed by this allocator. More... | |
virtual void | reset ()=0 |
Free all allocated elements. More... | |
virtual void | report (std::ostream &os) const |
Generate a report on the memory usage of this allocator. More... | |
Static Public Member Functions | |
template<class T > | |
static func_t * | makeConstructor (const std::false_type &) |
Make a constructor function pointer for a non-trivial constructor. More... | |
template<class T > | |
static func_t * | makeConstructor (const std::true_type &) |
Make a constructor function pointer for a trivial constructor. More... | |
template<class T > | |
static func_t * | makeDestructor (const std::false_type &) |
Make a constructor function pointer for a non-trivial destructor. More... | |
template<class T > | |
static func_t * | makeDestructor (const std::true_type &) |
Make a constructor function pointer for a trivial destructor. More... | |
template<class T > | |
static func_t * | makeClear (const std::false_type &) |
Make a function pointer for a clear function. More... | |
template<class T > | |
static func_t * | makeClear (const std::true_type &) |
Make a dummy clear function pointer. More... | |
Protected Member Functions | |
ArenaBlock * | getBlock () |
Return an empty block, either newly-allocated or from the free list. More... | |
Protected Attributes | |
Params | m_params |
The parameters for this allocator. More... | |
ArenaBlock * | m_blocks |
The list of blocks currently in use. More... | |
ArenaBlock * | m_freeblocks |
The list of free blocks. More... | |
ArenaAllocatorBase::Stats | m_stats |
The statistics structure. More... | |
bool | m_protected |
Flag whether the arena has been protected. More... | |
Static Private Member Functions | |
template<typename T > | |
static void | construct_fcn (pointer p) |
Call T's default constructor on the object at p . More... | |
template<typename T > | |
static void | destroy_fcn (pointer p) |
Call T's destructor on the object at p . More... | |
template<typename T > | |
static void | clear_fcn (pointer p) |
Call T::clear on the object at p . More... | |
Common functionality for block-oriented allocators.
See Arena.h for an overview of the arena-based memory allocators.
This class factors out some common functionality for allocators that use ArenaBlock
.
Definition at line 33 of file ArenaBlockAllocatorBase.h.
|
inherited |
And a const version of the pointer.
Definition at line 140 of file ArenaAllocatorBase.h.
|
inherited |
Type of functions for constructor
, etc.
Definition at line 143 of file ArenaAllocatorBase.h.
|
inherited |
Type for pointers to elements.
Definition at line 137 of file ArenaAllocatorBase.h.
Constructor.
params | The parameters structure for this allocator. See ArenaAllocatorBase.h for the contents. |
Definition at line 25 of file ArenaBlockAllocatorBase.cxx.
|
virtual |
Destructor.
Definition at line 38 of file ArenaBlockAllocatorBase.cxx.
|
delete |
Don't allow copy construction or assignment.
SG::ArenaBlockAllocatorBase::ArenaBlockAllocatorBase | ( | ArenaBlockAllocatorBase && | other | ) |
Move constructor.
Definition at line 50 of file ArenaBlockAllocatorBase.cxx.
|
staticprivateinherited |
Call T::clear
on the object at p
.
p | The object on which to run the clear . |
|
staticprivateinherited |
Call T's
default constructor on the object at p
.
p | The object on which to run the constructor. |
|
staticprivateinherited |
Call T's
destructor on the object at p
.
p | The object on which to run the destructor. |
|
overridevirtual |
Free all allocated elements and release memory back to the system.
All elements allocated are freed, and all allocated blocks of memory are released back to the system. destructor
should be called on them if it was provided (preceded by clear
if provided and mustClear
was set).
Implements SG::ArenaAllocatorBase.
Reimplemented in SG::ArenaPoolAllocator, and SG::ArenaHeapAllocator.
Definition at line 172 of file ArenaBlockAllocatorBase.cxx.
|
protected |
Return an empty block, either newly-allocated or from the free list.
Update statistics appropriately.
Definition at line 234 of file ArenaBlockAllocatorBase.cxx.
|
staticinherited |
Make a function pointer for a clear
function.
|
staticinherited |
Make a dummy clear
function pointer.
|
staticinherited |
Make a constructor function pointer for a non-trivial constructor.
|
staticinherited |
Make a constructor function pointer for a trivial constructor.
|
staticinherited |
Make a constructor function pointer for a non-trivial destructor.
|
staticinherited |
Make a constructor function pointer for a trivial destructor.
|
overridevirtual |
Return the name of this allocator.
Implements SG::ArenaAllocatorBase.
Definition at line 214 of file ArenaBlockAllocatorBase.cxx.
ArenaBlockAllocatorBase & SG::ArenaBlockAllocatorBase::operator= | ( | ArenaBlockAllocatorBase && | other | ) |
|
delete |
const ArenaAllocatorBase::Params & SG::ArenaBlockAllocatorBase::params | ( | ) | const |
Return this Allocator's parameters.
Return this allocator's parameters.
Definition at line 224 of file ArenaBlockAllocatorBase.cxx.
void SG::ArenaBlockAllocatorBase::protect | ( | ) |
Write-protect the memory managed by this allocator.
Adjust protection on the memory managed by this allocator to disallow writes.
Definition at line 270 of file ArenaBlockAllocatorBase.cxx.
|
virtualinherited |
Generate a report on the memory usage of this allocator.
os | Stream to which the report should be written. |
Definition at line 130 of file ArenaAllocatorBase.cxx.
|
overridevirtual |
Set the total number of elements cached by the allocator.
size | The desired pool size. |
This allows changing the number of elements that are currently free but cached. Any allocated elements are not affected by this call.
If size
is greater than the total number of elements currently cached, then more will be allocated. This will preferably done with a single block, but that is not guaranteed; in addition, the allocator may allocate more elements than is requested.
If size
is smaller than the total number of elements currently cached, as many blocks as possible will be released back to the system. It may not be possible to release the number of elements requested; this should be implemented on a best-effort basis.
Implements SG::ArenaAllocatorBase.
Definition at line 120 of file ArenaBlockAllocatorBase.cxx.
|
pure virtualinherited |
Free all allocated elements.
All elements allocated are returned to the free state. clear
should be called on them if it was provided. The elements may continue to be cached internally, without returning to the system.
Implemented in SG::ArenaPoolAllocator, and SG::ArenaHeapAllocator.
|
overridevirtual |
Return the statistics block for this allocator.
Implements SG::ArenaAllocatorBase.
Definition at line 196 of file ArenaBlockAllocatorBase.cxx.
void SG::ArenaBlockAllocatorBase::swap | ( | ArenaBlockAllocatorBase & | other | ) |
Swap.
Definition at line 91 of file ArenaBlockAllocatorBase.cxx.
void SG::ArenaBlockAllocatorBase::unprotect | ( | ) |
Write-enable the memory managed by this allocator.
Adjust protection on the memory managed by this allocator to allow writes.
Definition at line 283 of file ArenaBlockAllocatorBase.cxx.
|
protected |
The list of blocks currently in use.
Definition at line 153 of file ArenaBlockAllocatorBase.h.
|
protected |
The list of free blocks.
Definition at line 156 of file ArenaBlockAllocatorBase.h.
|
protected |
The parameters for this allocator.
Definition at line 150 of file ArenaBlockAllocatorBase.h.
|
protected |
Flag whether the arena has been protected.
Definition at line 162 of file ArenaBlockAllocatorBase.h.
|
protected |
The statistics structure.
Definition at line 159 of file ArenaBlockAllocatorBase.h.