-
Notifications
You must be signed in to change notification settings - Fork 8
shared_memory shared_memory
Alairion edited this page May 8, 2021
·
10 revisions
nes::shared_memory::shared_memory
(1) constexpr shared_memory() noexcept = default;
(2) explicit shared_memory(const std::string& name, std::uint64_t size);
(3) explicit shared_memory(const std::string& name, shared_memory_options options = shared_memory_options::none);
(4) shared_memory(const shared_memory&) = delete;
(5) shared_memory(shared_memory&& other) noexcept;- Constructs an empty shared memory. A default-constructed shared memory object is not associated with any memory.
- Creates a new shared memory object with the specified name and size. The newly created shared memory is filled with 0.
- Opens an existing shared memory object. If
optionsisnes::shared_memory_options::constantthen the shared memory object can only be mapped for read-only access. - Deleted copy-constructor.
- Move constructor. Initializes the new shared memory with the content
other. After this call, other does no longer represents any shared memory object.
| Name | Description |
|---|---|
name |
The UTF-8 encoded name of the shared memory object. The real name of the shared memory object is shared_memory_root + name. |
size |
The requested size, in bytes, of the shared memory object. The newly created shared memory object has a size of at least size bytes. |
options |
Additional flags. nes::shared_memory_options::constant prevents from read-write access to the shared memory. |
other |
An instance of nes::shared_memory
|
name must not be empty.
size must be more than 0.
options must be nes::shared_memory_options::none or nes::shared_memory_options::constant.
- Explicit.
- Explicit.
- Deleted.
- Does not throw.
- May throw a
std::runtime_errorif the shared memory can not be allocated. - May throw a
std::runtime_errorif the shared memory can not be opened. - Deleted.
- Does not throw.
- On Windows, the shared memory object is created using
CreateFileMappingWwith an invalid file handle
On Posix systems, the shared memory object is created usingshm_open, followed by a call toftruncate - On Windows, the shared memory object is opened using
OpenFileMappingW
On Posix systems, the shared memory object is openedshm_open