POSIX Shared Memory Data Structures 1.0
High-performance lock-free data structures for inter-process communication
|
POSIX shared memory wrapper with RAII and reference counting. More...
#include <posix_shm.h>
Public Types | |
using | table_type = TableType |
Type alias for the table type parameter. | |
Public Member Functions | |
posix_shm_impl (const std::string &name, size_t size=0) | |
Create or attach to a POSIX shared memory segment. | |
~posix_shm_impl () | |
Destructor with automatic cleanup. | |
void * | get_base_addr () const |
Get base address for user data (after header) | |
size_t | get_total_size () const |
Get usable size for data (excluding header) | |
TableType * | get_table () |
Get mutable pointer to metadata table. | |
const TableType * | get_table () const |
Get const pointer to metadata table. | |
int | get_ref_count () const |
Get current reference count. | |
bool | unlink () |
Explicitly unlink the shared memory segment. | |
posix_shm_impl (const posix_shm_impl &)=delete | |
Deleted copy constructor (non-copyable) | |
posix_shm_impl & | operator= (const posix_shm_impl &)=delete |
Deleted copy assignment (non-copyable) | |
POSIX shared memory wrapper with RAII and reference counting.
This class provides:
The shared memory layout:
TableType | The metadata table implementation (default: shm_table) |
Definition at line 61 of file posix_shm.h.
using posix_shm_impl< TableType >::table_type = TableType |
Type alias for the table type parameter.
Definition at line 330 of file posix_shm.h.
|
inline |
Create or attach to a POSIX shared memory segment.
name | Unique identifier for the shared memory segment |
size | Size in bytes (0 = attach to existing segment) |
std::runtime_error | if shm_open fails |
std::runtime_error | if mmap fails |
std::runtime_error | if ftruncate fails (when creating) |
Definition at line 121 of file posix_shm.h.
|
inline |
Destructor with automatic cleanup.
Performs the following:
Definition at line 204 of file posix_shm.h.
|
delete |
Deleted copy constructor (non-copyable)
|
inline |
Get base address for user data (after header)
Definition at line 222 of file posix_shm.h.
|
inline |
Get current reference count.
Definition at line 292 of file posix_shm.h.
|
inline |
Get mutable pointer to metadata table.
Definition at line 260 of file posix_shm.h.
|
inline |
Get const pointer to metadata table.
Definition at line 272 of file posix_shm.h.
|
inline |
Get usable size for data (excluding header)
Definition at line 241 of file posix_shm.h.
|
delete |
Deleted copy assignment (non-copyable)
|
inline |
Explicitly unlink the shared memory segment.
Definition at line 314 of file posix_shm.h.