16#ifndef ATLALLOCATORS_ARENAALLOCATORBASE_H
17#define ATLALLOCATORS_ARENAALLOCATORBASE_H
215 static void header (std::ostream& os);
283 virtual const std::string&
name()
const = 0;
290 virtual void report (std::ostream& os)
const;
312 template <
typename T,
314 bool no_ctor =
false,
315 bool no_dtor =
false>
321 "Requested Alignment larger than the one that can be provided");
377 template <
typename T>
385 template <
typename T>
393 template <
typename T>
421struct formatter<
SG::ArenaAllocatorBase::Stats::Stat>
422 :
public formatter<string_view>
424 template <
class FmtContext>
429struct formatter<
SG::ArenaAllocatorBase::Stats>
430 :
public formatter<string_view>
432 template <
class FmtContext>
A dummy pad struct to put at the end of the ArenaBlock header to ensure the alignment of the elements...
void clear()
Empty the pool.
Common base class for arena allocator classes.
char * pointer
Type for pointers to elements.
void func_t(pointer)
Type of functions for constructor, etc.
virtual ~ArenaAllocatorBase()
Destructor.
virtual void reset()=0
Free all allocated elements.
virtual void reserve(size_t size)=0
Set the total number of elements cached by the allocator.
virtual const std::string & name() const =0
Return the name of this allocator.
static func_t * makeConstructor(const std::false_type &)
Make a constructor function pointer for a non-trivial constructor.
static func_t * makeDestructor(const std::true_type &)
Make a constructor function pointer for a trivial destructor.
static func_t * makeClear(const std::false_type &)
Make a function pointer for a clear function.
static void clear_fcn(pointer p)
Call T::clear on the object at p.
static void construct_fcn(pointer p)
Call T's default constructor on the object at p.
const char * const_pointer
And a const version of the pointer.
virtual void erase()=0
Free all allocated elements and release memory back to the system.
virtual void report(std::ostream &os) const
Generate a report on the memory usage of this allocator.
virtual Stats stats() const =0
Return the statistics block for this allocator.
static void destroy_fcn(pointer p)
Call T's destructor on the object at p.
static func_t * makeClear(const std::true_type &)
Make a dummy clear function pointer.
static func_t * makeConstructor(const std::true_type &)
Make a constructor function pointer for a trivial constructor.
static func_t * makeDestructor(const std::false_type &)
Make a constructor function pointer for a non-trivial destructor.
constexpr size_t alignment
virtual size_t size() const override
Return the number of elements in the store.
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
func_t * constructor
Constructor function for elements.
func_t * clear
Clear function for elements.
size_t eltSize
The size in bytes of the individual elements we're allocating.
size_t linkOffset
Offset from the start of a free element to a pointer to be used by the allocator.
size_t nblock
The number of elements we should allocate in a single block (hint only).
func_t * destructor
Destructor function for elements.
size_t minSize
The minimum size that this Allocator allows for an element.
bool mustClear
If true, the clear call cannot be skipped before destructor.
bool canReclear
If true, clear can be called more than once on a given element.
std::string name
The name of this allocator.
Stat & operator+=(const Stat &other)
Accumulate.
void clear()
Reset to zero.
size_t free
Number of items currently not allocated by the application but cached by the allocator.
Stat()
Default constructor.
size_t inuse
Number of items currently allocated by the application.
size_t total
Total number of items held by the allocator.
Statistics for an allocator.
Stat blocks
Counts of blocks.
void clear()
Reset to zero.
Stat elts
Counts of elements.
static void header(std::ostream &os)
Print report header.
Stats & operator+=(const Stats &other)
Accumulate.
Stat bytes
Counts of bytes.
initParams(size_t nblock=1000, const std::string &name="")
Constructor.
Params params() const
Return an initialized parameters structure.