join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::HeapMem Class Reference

heap memory provider. More...

#include <memory.hpp>

Public Types

template<size_t Capacity, typename SyncPolicy = BumpAtomic>
using BumpAllocator = BasicBumpAllocator<HeapMem, Capacity, SyncPolicy>
 

Public Member Functions

 HeapMem () noexcept=default
 default constructor.
 
 HeapMem (uint64_t size)
 allocates a heap memory segment.
 
 HeapMem (const HeapMem &other)=delete
 copy constructor.
 
HeapMem & operator= (const HeapMem &other)=delete
 copy assignment operator.
 
 HeapMem (HeapMem &&other) noexcept
 move constructor.
 
HeapMem & operator= (HeapMem &&other) noexcept
 move assignment operator.
 
 ~HeapMem () noexcept
 releases the memory.
 
bool mapped () const noexcept
 check if the memory is allocated.
 
const void * get (uint64_t offset=0) const
 get a const pointer to the memory at a given offset.
 
void * get (uint64_t offset=0)
 get a pointer to the memory at a given offset.
 

Detailed Description

heap memory provider.

Member Typedef Documentation

◆ BumpAllocator

template<size_t Capacity, typename SyncPolicy = BumpAtomic>
using join::HeapMem::BumpAllocator = BasicBumpAllocator<HeapMem, Capacity, SyncPolicy>

Constructor & Destructor Documentation

◆ HeapMem() [1/4]

join::HeapMem::HeapMem ( )
defaultnoexcept

default constructor.

◆ HeapMem() [2/4]

join::HeapMem::HeapMem ( uint64_t size)
inlineexplicit

allocates a heap memory segment.

Parameters
sizeallocation size in bytes.
Exceptions
std::bad_allocif size is 0, too large or malloc fails.

◆ HeapMem() [3/4]

join::HeapMem::HeapMem ( const HeapMem & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ HeapMem() [4/4]

join::HeapMem::HeapMem ( HeapMem && other)
inlinenoexcept

move constructor.

Parameters
otherother object to move.

◆ ~HeapMem()

join::HeapMem::~HeapMem ( )
inlinenoexcept

releases the memory.

Member Function Documentation

◆ get() [1/2]

void * join::HeapMem::get ( uint64_t offset = 0)
inline

get a pointer to the memory at a given offset.

Parameters
offsetbyte offset from the start of the memory.
Returns
pointer to the memory at the specified offset.
Exceptions
std::runtime_errorif memory is not allocated.
std::out_of_rangeif offset is out of bounds.

◆ get() [2/2]

const void * join::HeapMem::get ( uint64_t offset = 0) const
inline

get a const pointer to the memory at a given offset.

Parameters
offsetbyte offset from the start of the memory.
Returns
pointer to the memory at the specified offset.
Exceptions
std::runtime_errorif memory is not allocated.
std::out_of_rangeif offset is out of bounds.

◆ mapped()

bool join::HeapMem::mapped ( ) const
inlinenoexcept

check if the memory is allocated.

Returns
true if the memory is allocated, false otherwise.

◆ operator=() [1/2]

HeapMem & join::HeapMem::operator= ( const HeapMem & other)
delete

copy assignment operator.

Parameters
otherother object to copy.
Returns
this.

◆ operator=() [2/2]

HeapMem & join::HeapMem::operator= ( HeapMem && other)
inlinenoexcept

move assignment operator.

Parameters
otherother object to move.
Returns
this.

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