ATLAS Offline Software
Loading...
Searching...
No Matches
SG::initParams< T, clear, no_ctor, no_dtor > Struct Template Reference

Heap-based allocator. More...

#include <ArenaHeapAllocator.h>

Inheritance diagram for SG::initParams< T, clear, no_ctor, no_dtor >:
Collaboration diagram for SG::initParams< T, clear, no_ctor, no_dtor >:

Public Types

typedef ArenaAllocatorBase::initParams< T, clear, no_ctor, no_dtor > Base

Public Member Functions

 initParams (size_t nblock=1000, const std::string &name="")
 Constructor.
ArenaAllocatorBase::Params params () const
 Return an initialized parameters structure.
 operator ArenaAllocatorBase::Params () const
 Return an initialized parameters structure.
 operator Params () const
 Return an initialized parameters structure.

Private Attributes

size_t m_nblock
 Saved value of the number of elements to allocate per block.
std::string m_name
 Saved value of the allocator name.

Detailed Description

template<typename T, bool clear = false, bool no_ctor = false, bool no_dtor = false>
struct SG::initParams< T, clear, no_ctor, no_dtor >

Heap-based allocator.

See Arena.h for an overview of the arena-based memory allocators.

This is a block-based memory allocator, with heap-like behavior. This allows freeing individual elements, but we don't implement resetTo or an iterator.

There are some extra costs though.

  • We need an additional pointer (`link') for each free element.

    By default, this is done by increasing the element size by a pointer, since we don't know whether there is data in the element itself that must be preserved across free/allocate. However, if you know that part of the element may be safely while it is free, then the allocator can be configured to use that as the link instead.

  • When reset() is called, we need to call clear() on all allocated elements (if it is defined). If canReclear is set, then we just call clear() on all elements in allocated blocks on reset(), regardless of whether or not the individual elements are allocated or not. Otherwise, we make two passes over the elements, first to build a list of those that are allocated and second to actually call clear().

    An intermediate strategy, not currently implemented, could be used if the link does not overlap the element: set the link to a magic value when an element is allocated. */ class ArenaHeapAllocator : public ArenaBlockAllocatorBase { public: /**

Helper to initialize a parameters structure.

This creates a Params class appropriately initialized for class T. Assumptions made:

  • The constructor and destructor calls will be filled in if non-trivial, unless no_ctor or no_dtor is set to true.
  • The clear call will be filled in if the optional template parameter clear is true.
  • No space will be reserved for an extra link.
  • canReclear is true and mustClear is false.
  • The link will be allocated externally to the element.

If these are not appropriate, you can derive from this class and make the appropriate changes.

Definition at line 86 of file ArenaHeapAllocator.h.

Member Typedef Documentation

◆ Base

template<typename T, bool clear = false, bool no_ctor = false, bool no_dtor = false>
typedef ArenaAllocatorBase::initParams<T, clear, no_ctor, no_dtor> SG::initParams< T, clear, no_ctor, no_dtor >::Base

Definition at line 90 of file ArenaHeapAllocator.h.

Constructor & Destructor Documentation

◆ initParams()

template<typename T, bool clear = false, bool no_ctor = false, bool no_dtor = false>
SG::initParams< T, clear, no_ctor, no_dtor >::initParams ( size_t nblock = 1000,
const std::string & name = "" )

Constructor.

Parameters
nblockValue to set in the parameters structure for the number of elements to allocate per block.
nameValue to set in the parameters structure for the allocator name.

Member Function Documentation

◆ operator ArenaAllocatorBase::Params()

template<typename T, bool clear = false, bool no_ctor = false, bool no_dtor = false>
SG::initParams< T, clear, no_ctor, no_dtor >::operator ArenaAllocatorBase::Params ( ) const
inline

Return an initialized parameters structure.

Definition at line 107 of file ArenaHeapAllocator.h.

107{ return params(); }
ArenaAllocatorBase::Params params() const
Return an initialized parameters structure.

◆ operator Params()

SG::ArenaAllocatorBase::initParams< T, clear, no_ctor, no_dtor >::operator Params ( ) const
inlineinherited

Return an initialized parameters structure.

Definition at line 335 of file ArenaAllocatorBase.h.

◆ params()

template<typename T, bool clear = false, bool no_ctor = false, bool no_dtor = false>
ArenaAllocatorBase::Params SG::initParams< T, clear, no_ctor, no_dtor >::params ( ) const

Return an initialized parameters structure.

Member Data Documentation

◆ m_name

std::string SG::ArenaAllocatorBase::initParams< T, clear, no_ctor, no_dtor >::m_name
privateinherited

Saved value of the allocator name.

Definition at line 343 of file ArenaAllocatorBase.h.

◆ m_nblock

size_t SG::ArenaAllocatorBase::initParams< T, clear, no_ctor, no_dtor >::m_nblock
privateinherited

Saved value of the number of elements to allocate per block.

Definition at line 340 of file ArenaAllocatorBase.h.


The documentation for this struct was generated from the following file: