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

local anonymous memory provider. More...

#include <memory.hpp>

Public Types

template<size_t Count, size_t... Sizes>
using Allocator = BasicArena<LocalMem, Count, Sizes...>
 
using Spsc = SyncBinding<LocalMem, ::join::Spsc>
 
using Mpsc = SyncBinding<LocalMem, ::join::Mpsc>
 
using Mpmc = SyncBinding<LocalMem, ::join::Mpmc>
 

Public Member Functions

 LocalMem (uint64_t size)
 allocates a local anonymous memory segment.
 
 LocalMem (const LocalMem &other)=delete
 copy constructor.
 
LocalMemoperator= (const LocalMem &other)=delete
 copy assignment operator.
 
 LocalMem (LocalMem &&other) noexcept
 move constructor.
 
LocalMemoperator= (LocalMem &&other) noexcept
 move assignment operator.
 
 ~LocalMem () noexcept
 releases the mapped memory.
 
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.
 
int mbind (int numa) const noexcept
 bind memory to a NUMA node.
 
int mlock () const noexcept
 lock memory in RAM.
 

Detailed Description

local anonymous memory provider.

Member Typedef Documentation

◆ Allocator

template<size_t Count, size_t... Sizes>
using join::LocalMem::Allocator = BasicArena<LocalMem, Count, Sizes...>

◆ Mpmc

◆ Mpsc

◆ Spsc

Constructor & Destructor Documentation

◆ LocalMem() [1/3]

join::LocalMem::LocalMem ( uint64_t size)
inlineexplicit

allocates a local anonymous memory segment.

Parameters
sizeallocation size in bytes.
Exceptions
std::system_errorif mmap fails.

◆ LocalMem() [2/3]

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

copy constructor.

Parameters
otherother object to copy.

◆ LocalMem() [3/3]

join::LocalMem::LocalMem ( LocalMem && other)
inlinenoexcept

move constructor.

Parameters
otherother object to move.

◆ ~LocalMem()

join::LocalMem::~LocalMem ( )
inlinenoexcept

releases the mapped memory.

Member Function Documentation

◆ get() [1/2]

void * join::LocalMem::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 mapped memory at the specified offset, or nullptr if not opened.
Exceptions
std::runtime_errorif memory is not mapped.
std::out_of_rangeif offset is out of bounds.

◆ get() [2/2]

const void * join::LocalMem::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 mapped memory at the specified offset, or nullptr if not opened.
Exceptions
std::runtime_errorif memory is not mapped.
std::out_of_rangeif offset is out of bounds.

◆ mbind()

int join::LocalMem::mbind ( int numa) const
inlinenoexcept

bind memory to a NUMA node.

Parameters
numaNUMA node ID.
Returns
0 on success, -1 on failure.

◆ mlock()

int join::LocalMem::mlock ( ) const
inlinenoexcept

lock memory in RAM.

Returns
0 on success, -1 on failure.

◆ operator=() [1/2]

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

copy assignment operator.

Parameters
otherother object to copy.
Returns
this.

◆ operator=() [2/2]

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

move assignment operator.

Parameters
otherother object to move.
Returns
this.

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