LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::FixedArena< T > Class Template Reference

#include <MemArena.h>

Collaboration diagram for swoc::FixedArena< T >:
Collaboration graph

Classes

struct  Item
 Rebinding type for instances on the free list. More...
 

Public Member Functions

 FixedArena (MemArena &arena)
 
template<typename... Args>
T * make (Args... args)
 
void destroy (T *t)
 
void clear ()
 Drop all items in the free list.
 
MemArenaarena ()
 Access the wrapped arena directly.
 

Protected Attributes

Item _list {nullptr}
 List of dead instances.
 
MemArena_arena
 Memory source.
 

Detailed Description

template<typename T>
class swoc::FixedArena< T >

Arena of a specific type on top of a MemArena.

Template Parameters
TType in the arena.

A pool of unused / free instances of T is kept for reuse. If none are available then a new instance is allocated from the arena.

Definition at line 528 of file MemArena.h.

Constructor & Destructor Documentation

◆ FixedArena()

template<typename T>
swoc::FixedArena< T >::FixedArena ( MemArena & arena)
explicit

Construct a pool.

Parameters
arenaThe arena for memory.

Member Function Documentation

◆ destroy()

template<typename T>
void swoc::FixedArena< T >::destroy ( T * t)

Destroy an instance.

Parameters
tThe instance to destroy.

The instance is destructed and then put on the free list for re-use.

◆ make()

template<typename T>
template<typename... Args>
T * swoc::FixedArena< T >::make ( Args... args)

Create a new instance.

Template Parameters
ArgsConstructor argument types.
Parameters
argsConstructor arguments.
Returns
A new instance of T.

Member Data Documentation

◆ _arena

template<typename T>
MemArena& swoc::FixedArena< T >::_arena
protected

Memory source.

Definition at line 537 of file MemArena.h.

◆ _list

template<typename T>
Item swoc::FixedArena< T >::_list {nullptr}
protected

List of dead instances.

Definition at line 536 of file MemArena.h.


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