![]() |
Contur 2
Educational OS kernel simulator
|
Named shared-memory IPC channel. More...
#include <shared_memory.h>
Public Member Functions | |
| SharedMemory (std::string name, std::size_t bytes) | |
| Creates a named shared-memory region. | |
| ~SharedMemory () override | |
| Destroys shared-memory channel. | |
| SharedMemory (const SharedMemory &)=delete | |
| Copy construction is disabled. | |
| SharedMemory & | operator= (const SharedMemory &)=delete |
| Copy assignment is disabled. | |
| SharedMemory (SharedMemory &&) noexcept | |
| Move-constructs shared-memory state. | |
| SharedMemory & | operator= (SharedMemory &&) noexcept |
| Move-assigns shared-memory state. | |
| Result< std::size_t > | write (std::span< const std::byte > data) override |
| Writes bytes into the beginning of the shared region. | |
| Result< std::size_t > | read (std::span< std::byte > buffer) override |
| Reads bytes from the beginning of the shared region. | |
| void | close () override |
| Closes the region, clears attachments, and resets data. | |
| bool | isOpen () const noexcept override |
| Returns whether the region is open. | |
| std::string_view | name () const noexcept override |
| Region name. | |
| Result< void > | attach (ProcessId pid) |
| Attaches a process to this region. | |
| Result< void > | detach (ProcessId pid) |
| Detaches a process from this region. | |
| bool | isAttached (ProcessId pid) const noexcept |
| Returns true if process is attached. | |
| std::size_t | attachedCount () const noexcept |
| Number of attached processes. | |
| std::size_t | size () const noexcept |
| Region size in bytes. | |
| Public Member Functions inherited from contur::IIpcChannel | |
| virtual | ~IIpcChannel ()=default |
Private Attributes | |
| 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.
|
explicit |
Creates a named shared-memory region.
| name | Channel name. |
| bytes | Size of memory region in bytes. |
References name().
Referenced by operator=(), operator=(), SharedMemory(), and SharedMemory().
|
override |
Destroys shared-memory channel.
|
delete |
Copy construction is disabled.
References SharedMemory().
|
noexcept |
Move-constructs shared-memory state.
References SharedMemory().
|
nodiscardnoexcept |
|
overridevirtual |
Closes the region, clears attachments, and resets data.
Implements contur::IIpcChannel.
References close().
Referenced by close().
|
nodiscardnoexcept |
|
nodiscardoverridevirtualnoexcept |
Returns whether the region is open.
Implements contur::IIpcChannel.
References isOpen().
Referenced by isOpen().
|
nodiscardoverridevirtualnoexcept |
Region name.
Implements contur::IIpcChannel.
References name().
Referenced by name(), and SharedMemory().
|
delete |
Copy assignment is disabled.
References SharedMemory().
|
noexcept |
Move-assigns shared-memory state.
References SharedMemory().
|
nodiscardoverridevirtual |
Reads bytes from the beginning of the shared region.
Implements contur::IIpcChannel.
References read().
Referenced by read().
|
nodiscardnoexcept |
|
nodiscardoverridevirtual |
Writes bytes into the beginning of the shared region.
Implements contur::IIpcChannel.
References write().
Referenced by write().
|
private |
Definition at line 79 of file shared_memory.h.