...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::shared_memory_object
class shared_memory_object { public: // construct/copy/destruct shared_memory_object(); shared_memory_object(create_only_t, const char *, mode_t); shared_memory_object(open_or_create_t, const char *, mode_t); shared_memory_object(open_only_t, const char *, mode_t); shared_memory_object(unspecified); shared_memory_object& operator=(unspecified); ~shared_memory_object(); // public member functions void swap(shared_memory_object &) ; void truncate(offset_t) ; const char * get_name() const; bool get_size(offset_t &) const; mode_t get_mode() const; mapping_handle_t get_mapping_handle() const; // public static functions static bool remove(const char *) ; };
A class that wraps a shared memory mapping that can be used to create mapped regions from the mapped files
shared_memory_object
public
construct/copy/destructshared_memory_object();
Default constructor. Represents an empty shared_memory_object.
shared_memory_object(create_only_t, const char * name, mode_t mode);
Creates a shared memory object with name "name" and mode "mode", with the access mode "mode" If the file previously exists, throws an error.
shared_memory_object(open_or_create_t, const char * name, mode_t mode);
Tries to create a shared memory object with name "name" and mode "mode", with the access mode "mode". If the file previously exists, it tries to open it with mode "mode". Otherwise throws an error.
shared_memory_object(open_only_t, const char * name, mode_t mode);
Tries to open a shared memory object with name "name", with the access mode "mode". If the file does not previously exist, it throws an error.
shared_memory_object(unspecified moved);
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
shared_memory_object& operator=(unspecified moved);
Moves the ownership of "moved"'s shared memory to *this. After the call, "moved" does not represent any shared memory. Does not throw
~shared_memory_object();
Destroys *this and indicates that the calling process is finished using the resource. All mapped regions are still valid after destruction. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
shared_memory_object
public member functionsvoid swap(shared_memory_object & other) ;
void truncate(offset_t length) ;
const char * get_name() const;
bool get_size(offset_t & size) const;
Returns the name of the file used in the constructor
mode_t get_mode() const;
mapping_handle_t get_mapping_handle() const;