...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::interprocess::xsi_shared_memory
// In header: <boost/interprocess/xsi_shared_memory.hpp> class xsi_shared_memory { public: // construct/copy/destruct xsi_shared_memory() noexcept; xsi_shared_memory(open_only_t, int); xsi_shared_memory(create_only_t, const xsi_key &, std::size_t, const permissions & = permissions()); xsi_shared_memory(open_or_create_t, const xsi_key &, std::size_t, const permissions & = permissions()); xsi_shared_memory(open_only_t, const xsi_key &); xsi_shared_memory(xsi_shared_memory &&) noexcept; xsi_shared_memory & operator=(xsi_shared_memory &&) noexcept; ~xsi_shared_memory(); // public member functions void swap(xsi_shared_memory &) noexcept; int get_shmid() const noexcept; mapping_handle_t get_mapping_handle() const noexcept; // public static functions static bool remove(int); };
A class that wraps XSI (System V) shared memory. Unlike shared_memory_object, xsi_shared_memory needs a valid xsi_key to identify a shared memory object.
Warning: XSI shared memory and interprocess portable shared memory (boost::interprocess::shared_memory_object) can't communicate between them.
xsi_shared_memory
public
construct/copy/destructxsi_shared_memory() noexcept;
Default constructor. Represents an empty xsi_shared_memory
.
xsi_shared_memory(open_only_t, int shmid);
Initializes *this with a shmid previously obtained (possibly from another process) This lower-level initializer allows shared memory mapping without having a key.
xsi_shared_memory(create_only_t, const xsi_key & key, std::size_t size, const permissions & perm = permissions());
Creates a new XSI shared memory from 'key', with size "size" and permissions "perm". If the shared memory previously exists, throws an error.
xsi_shared_memory(open_or_create_t, const xsi_key & key, std::size_t size, const permissions & perm = permissions());
Opens an existing shared memory with identifier 'key' or creates a new XSI shared memory from identifier 'key', with size "size" and permissions "perm".
xsi_shared_memory(open_only_t, const xsi_key & key);
Tries to open a XSI shared memory with identifier 'key' If the shared memory does not previously exist, it throws an error.
xsi_shared_memory(xsi_shared_memory && moved) noexcept;
Moves the ownership of "moved"'s shared memory object to *this. After the call, "moved" does not represent any shared memory object. Does not throw
xsi_shared_memory & operator=(xsi_shared_memory && moved) noexcept;
Moves the ownership of "moved"'s shared memory to *this. After the call, "moved" does not represent any shared memory. Does not throw
~xsi_shared_memory();
Destroys *this. The shared memory won't be destroyed, just this connection to it. Use remove() to destroy the shared memory.
xsi_shared_memory
public member functionsvoid swap(xsi_shared_memory & other) noexcept;Swaps two xsi_shared_memorys. Does not throw.
int get_shmid() const noexcept;
Returns the shared memory ID that identifies the shared memory
mapping_handle_t get_mapping_handle() const noexcept;
Returns the mapping handle. Never throws