A shared memory object that uses the Boost interprocess library. More...
#include <MSharedMemoryObject.hpp>
Public Member Functions | |
template<typename ... P> | |
MSharedMemoryObject (const P &... params) | |
Create a shared memory object of type T with the supplied input arguments. More... | |
template<typename ... P> | |
MSharedMemoryObject (CreateOnlySelector, const std::string &name, const P &... params) | |
Create a shared memory object of type T with the supplied input arguments. More... | |
template<typename ... P> | |
MSharedMemoryObject (OpenOrCreateSelector, const std::string &name, const P &... params) | |
Create or open a shared memory object of type T with the supplied input arguments. More... | |
MSharedMemoryObject (OpenOnlySelector, const std::string &name) | |
Open a shared memory object of type T. More... | |
MSharedMemoryObject (OpenReadOnlySelector, const std::string &name) | |
Open read-only a shared memory object of type T. More... | |
MSharedMemoryObject (MSharedMemoryObject &&rhs) noexcept | |
Create a shared memory object by moving from a previously created one. More... | |
~MSharedMemoryObject () | |
Destroy the shared memory object. More... | |
T & | operator* () |
Get a reference to the shared memory object. More... | |
const T & | operator* () const |
Get a const reference to the shared memory object. More... | |
T * | operator-> () |
Get the shared memory object pointer. More... | |
const T * | operator-> () const |
Get the shared memory object pointer. More... | |
MSharedMemoryObject & | operator= (MSharedMemoryObject &&rhs) noexcept |
Assign a shared memory object by moving from a previously created one. More... | |
A shared memory object that uses the Boost interprocess library.
This version uses managed shared memory which does not require a call to remap in the child process after forking.
Note that shared memory is typically allocated in 4k pages, and a whole page will be allocated even if the object size is a single byte.
Note that the management state requires 512 bytes of the 4k page, so the maximum object size is 3.5KB before a second page is used.
This template class encapsulates the calls to the Boost interprocess library in order to create a shared memory object, and provides a simple API to construct/open and use the object.
Note that when using this class, the type T must have a POD type structure. If the type contains pointers, the objects pointed to will not share and consequently your application will be defective.
|
inlineexplicit |
Create a shared memory object of type T with the supplied input arguments.
The name prefix is automatically generated.
|
inline |
Create a shared memory object of type T with the supplied input arguments.
The specified name prefix is used.
|
inline |
Create or open a shared memory object of type T with the supplied input arguments.
The specified name prefix is used.
If the object already exists, it is opened and the supplied parameters are ignored.
|
inline |
Open a shared memory object of type T.
The specified name prefix is used.
NotFoundException | if no such shared memory object exists |
|
inline |
Open read-only a shared memory object of type T.
The specified name prefix is used.
NotFoundException | if no such shared memory object exists |
|
inline |
Destroy the shared memory object.
|
inlinenoexcept |
Create a shared memory object by moving from a previously created one.
|
inline |
Get a reference to the shared memory object.
|
inline |
Get a const reference to the shared memory object.
|
inline |
Get the shared memory object pointer.
|
inline |
Get the shared memory object pointer.
|
inlinenoexcept |
Assign a shared memory object by moving from a previously created one.