Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::ipc::SharedMemory Class Reference

Cross-platform zero-copy shared memory region wrapper. Manages OS-level shared memory allocation, memory mapping, and cleanup. More...

#include <SharedMemory.hpp>

+ Collaboration diagram for corium::ipc::SharedMemory:

Public Types

enum class  AccessMode : uint8_t { CreateOrOpen , OpenReadOnly , OpenReadWrite }
 

Public Member Functions

void close () noexcept
 Close and unmap the shared memory segment.
 
const void * data () const noexcept
 
void * data () noexcept
 Raw pointer to mapped shared memory buffer.
 
bool isCreator () const noexcept
 Check if this process created the memory segment (useful for initialization).
 
bool isValid () const noexcept
 Check if mapped region is valid.
 
const std::string & name () const noexcept
 Name identifier of shared memory.
 
bool open (const std::string &name, std::size_t size, AccessMode mode=AccessMode::CreateOrOpen) noexcept
 Create or attach to a shared memory region.
 
SharedMemoryoperator= (const SharedMemory &)=delete
 
SharedMemoryoperator= (SharedMemory &&other) noexcept
 
 SharedMemory () noexcept=default
 
 SharedMemory (const SharedMemory &)=delete
 
 SharedMemory (SharedMemory &&other) noexcept
 
std::size_t size () const noexcept
 Size of mapped shared memory buffer.
 
 ~SharedMemory ()
 

Static Public Member Functions

static void unlink (const std::string &name) noexcept
 Remove shared memory identifier from OS namespace (POSIX shm_unlink).
 

Detailed Description

Cross-platform zero-copy shared memory region wrapper. Manages OS-level shared memory allocation, memory mapping, and cleanup.

Member Enumeration Documentation

◆ AccessMode

enum class corium::ipc::SharedMemory::AccessMode : uint8_t
strong
Enumerator
CreateOrOpen 
OpenReadOnly 
OpenReadWrite 

Constructor & Destructor Documentation

◆ SharedMemory() [1/3]

corium::ipc::SharedMemory::SharedMemory ( )
defaultnoexcept

◆ ~SharedMemory()

corium::ipc::SharedMemory::~SharedMemory ( )
inline
+ Here is the call graph for this function:

◆ SharedMemory() [2/3]

corium::ipc::SharedMemory::SharedMemory ( const SharedMemory )
delete

◆ SharedMemory() [3/3]

corium::ipc::SharedMemory::SharedMemory ( SharedMemory &&  other)
inlinenoexcept

Member Function Documentation

◆ close()

void corium::ipc::SharedMemory::close ( )
inlinenoexcept

Close and unmap the shared memory segment.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ data() [1/2]

const void * corium::ipc::SharedMemory::data ( ) const
inlinenoexcept

◆ data() [2/2]

void * corium::ipc::SharedMemory::data ( )
inlinenoexcept

Raw pointer to mapped shared memory buffer.

+ Here is the caller graph for this function:

◆ isCreator()

bool corium::ipc::SharedMemory::isCreator ( ) const
inlinenoexcept

Check if this process created the memory segment (useful for initialization).

◆ isValid()

bool corium::ipc::SharedMemory::isValid ( ) const
inlinenoexcept

Check if mapped region is valid.

+ Here is the caller graph for this function:

◆ name()

const std::string & corium::ipc::SharedMemory::name ( ) const
inlinenoexcept

Name identifier of shared memory.

+ Here is the caller graph for this function:

◆ open()

bool corium::ipc::SharedMemory::open ( const std::string &  name,
std::size_t  size,
AccessMode  mode = AccessMode::CreateOrOpen 
)
inlinenoexcept

Create or attach to a shared memory region.

Parameters
nameUnique system identifier (e.g., "/corium_telemetry_shm").
sizeRequired memory segment capacity in bytes.
modeAllocation/Access mode.
Returns
true on success, false otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

SharedMemory & corium::ipc::SharedMemory::operator= ( const SharedMemory )
delete

◆ operator=() [2/2]

SharedMemory & corium::ipc::SharedMemory::operator= ( SharedMemory &&  other)
inlinenoexcept
+ Here is the call graph for this function:

◆ size()

std::size_t corium::ipc::SharedMemory::size ( ) const
inlinenoexcept

Size of mapped shared memory buffer.

+ Here is the caller graph for this function:

◆ unlink()

static void corium::ipc::SharedMemory::unlink ( const std::string &  name)
inlinestaticnoexcept

Remove shared memory identifier from OS namespace (POSIX shm_unlink).

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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