Cbeam
Loading...
Searching...
No Matches
cbeam::memory::interprocess_shared_memory Class Reference

Provides a unified, platform-independent interface for managing shared memory segments. More...

#include <interprocess_shared_memory.hpp>

Inheritance diagram for cbeam::memory::interprocess_shared_memory:

Classes

class  lock_guard
 

Public Member Functions

 interprocess_shared_memory (const std::string &unique_identifier, std::size_t size)
 Constructor that initializes the shared memory segment.
 
virtual ~interprocess_shared_memory () noexcept
 
void * data () const
 Retrieves the starting address of the shared memory region.
 
size_t capacity () const noexcept
 Returns the size of the shared memory region.
 
lock_guard get_lock_guard () const
 Acquires a lock_guard for mutex synchronization.
 
 interprocess_shared_memory (const interprocess_shared_memory &)=delete
 
interprocess_shared_memoryoperator= (const interprocess_shared_memory &)=delete
 
 interprocess_shared_memory (interprocess_shared_memory &&)=delete
 
interprocess_shared_memoryoperator= (interprocess_shared_memory &&)=delete
 

Detailed Description

Provides a unified, platform-independent interface for managing shared memory segments.

This class works similar to boost::interprocess::shared_memory_object with the difference that the shared memory is destroyed when the last processes that uses it exits. The design aligns with common use cases where persistent shared memory in kernel space is not a requirement. Furthermore, under Windows it uses native API, like boost::interprocess::windows_shared_memory does (avoiding file system permission problems under C:\ProgramData\boost_interprocess). Under Windows, the shared memory is only accessible from processes in the same user session.

Constructor & Destructor Documentation

◆ interprocess_shared_memory() [1/3]

cbeam::memory::interprocess_shared_memory::interprocess_shared_memory ( const std::string & unique_identifier,
std::size_t size )
inline

Constructor that initializes the shared memory segment.

Parameters
unique_identifierA unique identifier for the shared memory segment.
sizeThe initial size of the shared memory segment.

◆ ~interprocess_shared_memory()

virtual cbeam::memory::interprocess_shared_memory::~interprocess_shared_memory ( )
inlinevirtualnoexcept

◆ interprocess_shared_memory() [2/3]

cbeam::memory::interprocess_shared_memory::interprocess_shared_memory ( const interprocess_shared_memory & )
delete

◆ interprocess_shared_memory() [3/3]

cbeam::memory::interprocess_shared_memory::interprocess_shared_memory ( interprocess_shared_memory && )
delete

Member Function Documentation

◆ capacity()

size_t cbeam::memory::interprocess_shared_memory::capacity ( ) const
inlinenoexcept

Returns the size of the shared memory region.

Returns
The size of the shared memory region in bytes.

◆ data()

void * cbeam::memory::interprocess_shared_memory::data ( ) const
inline

Retrieves the starting address of the shared memory region.

W

Returns
A pointer to the beginning of the shared memory region.

◆ get_lock_guard()

lock_guard cbeam::memory::interprocess_shared_memory::get_lock_guard ( ) const
inline

Acquires a lock_guard for mutex synchronization.

Returns
A lock_guard object that locks the mutex until destruction (while it is in scope).

◆ operator=() [1/2]

interprocess_shared_memory & cbeam::memory::interprocess_shared_memory::operator= ( const interprocess_shared_memory & )
delete

◆ operator=() [2/2]

interprocess_shared_memory & cbeam::memory::interprocess_shared_memory::operator= ( interprocess_shared_memory && )
delete

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