Named shared-memory IPC channel.
More...
#include <shared_memory.h>
|
| std::unique_ptr< Impl > | impl_ |
Named shared-memory IPC channel.
SharedMemory exposes a fixed-size byte region that can be attached by multiple processes. Attach/detach tracking is managed internally.
Definition at line 19 of file shared_memory.h.
◆ SharedMemory() [1/3]
| contur::SharedMemory::SharedMemory |
( |
std::string | name, |
|
|
std::size_t | bytes ) |
|
explicit |
Creates a named shared-memory region.
- Parameters
-
| name | Channel name. |
| bytes | Size of memory region in bytes. |
◆ ~SharedMemory()
| contur::SharedMemory::~SharedMemory |
( |
| ) |
|
|
override |
◆ SharedMemory() [2/3]
| contur::SharedMemory::SharedMemory |
( |
const SharedMemory & | | ) |
|
|
delete |
◆ SharedMemory() [3/3]
| contur::SharedMemory::SharedMemory |
( |
SharedMemory && | | ) |
|
|
noexcept |
◆ attach()
Attaches a process to this region.
- Parameters
-
- Returns
- Ok on success, or InvalidPid/InvalidState.
◆ attachedCount()
| std::size_t contur::SharedMemory::attachedCount |
( |
| ) |
const |
|
nodiscardnoexcept |
Number of attached processes.
◆ close()
| void contur::SharedMemory::close |
( |
| ) |
|
|
overridevirtual |
◆ detach()
Detaches a process from this region.
- Parameters
-
- Returns
- Ok on success, or InvalidPid/NotFound.
◆ isAttached()
| bool contur::SharedMemory::isAttached |
( |
ProcessId | pid | ) |
const |
|
nodiscardnoexcept |
Returns true if process is attached.
◆ isOpen()
| bool contur::SharedMemory::isOpen |
( |
| ) |
const |
|
nodiscardoverridevirtualnoexcept |
◆ name()
| std::string_view contur::SharedMemory::name |
( |
| ) |
const |
|
nodiscardoverridevirtualnoexcept |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ read()
| Result< std::size_t > contur::SharedMemory::read |
( |
std::span< std::byte > | buffer | ) |
|
|
nodiscardoverridevirtual |
Reads bytes from the beginning of the shared region.
- Returns
- Number of bytes read (can be partial), or error.
Implements contur::IIpcChannel.
◆ size()
| std::size_t contur::SharedMemory::size |
( |
| ) |
const |
|
nodiscardnoexcept |
◆ write()
| Result< std::size_t > contur::SharedMemory::write |
( |
std::span< const std::byte > | data | ) |
|
|
nodiscardoverridevirtual |
Writes bytes into the beginning of the shared region.
- Returns
- Number of bytes written (can be partial), or error.
Implements contur::IIpcChannel.
◆ impl_
| std::unique_ptr<Impl> contur::SharedMemory::impl_ |
|
private |
The documentation for this class was generated from the following file: