Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::mem::FixedArenaAllocator Class Referencefinal

PMR arena with fixed runtime capacity. More...

#include <fixed_arena_allocator.hpp>

Inheritance diagram for helios::mem::FixedArenaAllocator:

Public Member Functions

 FixedArenaAllocator (size_t capacity) noexcept
 Constructs fixed arena with the given backing capacity.
 FixedArenaAllocator (const FixedArenaAllocator &)=delete
 FixedArenaAllocator (FixedArenaAllocator &&other) noexcept
 Move-constructs fixed arena from another instance.
 ~FixedArenaAllocator () noexcept override
FixedArenaAllocatoroperator= (const FixedArenaAllocator &)=delete
FixedArenaAllocatoroperator= (FixedArenaAllocator &&other) noexcept
 Move-assigns fixed arena state from another instance.
void Reset () noexcept
 Soft-resets bump offset and statistics.
bool Empty () const noexcept
 Returns true when no bytes have been bumped.
bool Owns (const void *ptr) const noexcept
 Checks whether pointer belongs to this arena's backing buffer.
AllocatorStats Stats () const noexcept
 Returns runtime statistics snapshot.
size_t InitialCapacity () const noexcept
 Returns configured backing capacity.
size_t TotalCapacity () const noexcept
 Returns configured backing capacity.

Detailed Description

PMR arena with fixed runtime capacity.

Lock-free bump allocation with no growth. Individual deallocation is a no-op; memory is reclaimed by Reset() or destruction.

Warning
Reset() must not run concurrently with allocate.

Definition at line 21 of file fixed_arena_allocator.hpp.

Constructor & Destructor Documentation

◆ FixedArenaAllocator() [1/3]

helios::mem::FixedArenaAllocator::FixedArenaAllocator ( size_t capacity)
inlineexplicitnoexcept

Constructs fixed arena with the given backing capacity.

Warning
Triggers assertion if capacity == 0. Triggers verification failure if backing allocation fails.
Parameters
capacityBacking buffer size in bytes

Definition at line 108 of file fixed_arena_allocator.hpp.

◆ FixedArenaAllocator() [2/3]

helios::mem::FixedArenaAllocator::FixedArenaAllocator ( const FixedArenaAllocator & )
delete

◆ FixedArenaAllocator() [3/3]

helios::mem::FixedArenaAllocator::FixedArenaAllocator ( FixedArenaAllocator && other)
inlinenoexcept

Move-constructs fixed arena from another instance.

Parameters
otherSource allocator; left in empty moved-from state

Definition at line 36 of file fixed_arena_allocator.hpp.

◆ ~FixedArenaAllocator()

helios::mem::FixedArenaAllocator::~FixedArenaAllocator ( )
inlineoverridenoexcept

Definition at line 37 of file fixed_arena_allocator.hpp.

Member Function Documentation

◆ Empty()

bool helios::mem::FixedArenaAllocator::Empty ( ) const
inlinenodiscardnoexcept

Returns true when no bytes have been bumped.

Returns
True if empty, false otherwise

Definition at line 58 of file fixed_arena_allocator.hpp.

◆ InitialCapacity()

size_t helios::mem::FixedArenaAllocator::InitialCapacity ( ) const
inlinenodiscardnoexcept

Returns configured backing capacity.

Returns
Capacity in bytes

Definition at line 79 of file fixed_arena_allocator.hpp.

◆ operator=() [1/2]

FixedArenaAllocator & helios::mem::FixedArenaAllocator::operator= ( const FixedArenaAllocator & )
delete

◆ operator=() [2/2]

FixedArenaAllocator & helios::mem::FixedArenaAllocator::operator= ( FixedArenaAllocator && other)
inlinenoexcept

Move-assigns fixed arena state from another instance.

Parameters
otherSource allocator; left in empty moved-from state
Returns
Reference to this allocator

Definition at line 117 of file fixed_arena_allocator.hpp.

◆ Owns()

bool helios::mem::FixedArenaAllocator::Owns ( const void * ptr) const
inlinenodiscardnoexcept

Checks whether pointer belongs to this arena's backing buffer.

Parameters
ptrPointer to test
Returns
True when owned, false otherwise

Definition at line 139 of file fixed_arena_allocator.hpp.

◆ Reset()

void helios::mem::FixedArenaAllocator::Reset ( )
inlinenoexcept

Soft-resets bump offset and statistics.

Warning
Must not be called concurrently with allocate.

Definition at line 128 of file fixed_arena_allocator.hpp.

◆ Stats()

AllocatorStats helios::mem::FixedArenaAllocator::Stats ( ) const
inlinenodiscardnoexcept

Returns runtime statistics snapshot.

Returns
Allocator stats for this arena

Definition at line 151 of file fixed_arena_allocator.hpp.

◆ TotalCapacity()

size_t helios::mem::FixedArenaAllocator::TotalCapacity ( ) const
inlinenodiscardnoexcept

Returns configured backing capacity.

Returns
Capacity in bytes

Definition at line 85 of file fixed_arena_allocator.hpp.