CppCommon
1.0.4.1
C++ Common Library
|
Shared memory manager. More...
#include <shared_memory.h>
Public Member Functions | |
SharedMemory (const std::string &name, size_t size) | |
Create a new or open existing block of shared memory with a given name and size. More... | |
SharedMemory (const SharedMemory &)=delete | |
SharedMemory (SharedMemory &&shmem)=delete | |
~SharedMemory () | |
SharedMemory & | operator= (const SharedMemory &)=delete |
SharedMemory & | operator= (SharedMemory &&shmem)=delete |
operator bool () const | |
Check if the shared memory block is valid. More... | |
const std::string & | name () const noexcept |
Get the shared memory block name. More... | |
size_t | size () const noexcept |
Get the shared memory block size. More... | |
void * | ptr () |
Get the shared memory block pointer. More... | |
const void * | ptr () const |
Get the constant shared memory block pointer. More... | |
bool | owner () const |
Get the shared memory owner flag (true if the new one was created, false if the existing one was opened) More... | |
Shared memory manager.
Shared memory manager allows to create named memory buffers shared between multiple processes. This is one of the common ways to organize different kinds of IPC (inter-process communication).
Not thread-safe.
https://en.wikipedia.org/wiki/Shared_memory_(interprocess_communication)
Definition at line 28 of file shared_memory.h.
|
explicit |
Create a new or open existing block of shared memory with a given name and size.
name | - Shared memory block name |
size | - Shared memory block size |
Definition at line 187 of file shared_memory.cpp.
|
delete |
|
delete |
CppCommon::SharedMemory::~SharedMemory | ( | ) |
Definition at line 198 of file shared_memory.cpp.
|
inlinenoexcept |
Get the shared memory block name.
Definition at line 48 of file shared_memory.h.
|
inlineexplicit |
Check if the shared memory block is valid.
Definition at line 45 of file shared_memory.h.
|
delete |
|
delete |
bool CppCommon::SharedMemory::owner | ( | ) | const |
Get the shared memory owner flag (true if the new one was created, false if the existing one was opened)
Definition at line 206 of file shared_memory.cpp.
void * CppCommon::SharedMemory::ptr | ( | ) |
Get the shared memory block pointer.
Definition at line 204 of file shared_memory.cpp.
const void * CppCommon::SharedMemory::ptr | ( | ) | const |
Get the constant shared memory block pointer.
Definition at line 205 of file shared_memory.cpp.
|
inlinenoexcept |
Get the shared memory block size.
Definition at line 50 of file shared_memory.h.