A shared memory object that uses the Boost interprocess library. More...
#include <USharedMemoryObject.hpp>
Public Member Functions | |
template<typename ... P> | |
USharedMemoryObject (const P &... params) | |
Create a shared memory object of type T with the supplied input arguments. More... | |
template<typename ... P> | |
USharedMemoryObject (boost::interprocess::create_only_t, std::string name_, const P &... params) | |
Create a shared memory object of type T with the supplied input arguments. More... | |
template<typename ... P> | |
USharedMemoryObject (boost::interprocess::open_or_create_t, std::string name_, const P &... params) | |
Create or open a shared memory object of type T with the supplied input arguments. More... | |
USharedMemoryObject (boost::interprocess::open_only_t, std::string name_) | |
Open a shared memory object of type T and with the specified name. More... | |
USharedMemoryObject (boost::interprocess::open_read_only_t, std::string name_) | |
Open read-only a shared memory object of type T and with the specified name. More... | |
USharedMemoryObject (USharedMemoryObject &&rhs) noexcept | |
Create a shared memory object by moving from a previously created one. 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... | |
USharedMemoryObject & | operator= (USharedMemoryObject &&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 unmanaged shared memory which requires 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.
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.
An automatically generated name is used.
|
inline |
Create a shared memory object of type T with the supplied input arguments.
The specified name is used.
|
inline |
Create or open a shared memory object of type T with the supplied input arguments.
The specified name 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 and with the specified name.
|
inline |
Open read-only a shared memory object of type T and with the specified name.
|
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.