shared memory class.
More...
#include <shared.hpp>
|
| | SharedMemory (const std::string &name, uint64_t size) |
| | create instance.
|
| |
| virtual | ~SharedMemory () |
| | destroy the instance.
|
| |
| virtual int | open () |
| | open or create the shared memory.
|
| |
| bool | opened () const noexcept |
| | check if shared memory is opened.
|
| |
| virtual void | close () noexcept |
| | close the shared memory.
|
| |
| virtual const void * | get (uint64_t offset=0) const |
| | get a const pointer to the shared memory at a given offset.
|
| |
| virtual void * | get (uint64_t offset=0) |
| | get a pointer to the shared memory at a given offset.
|
| |
| virtual uint64_t | size () const noexcept |
| | get the size of the shared memory.
|
| |
|
| static int | unlink (const std::string &name) noexcept |
| | destroy synchronization primitives and unlink the shared memory segment.
|
| |
|
| std::string | _name |
| | shared memory name.
|
| |
| uint64_t | _size = 0 |
| | shared memory size.
|
| |
| void * | _ptr = nullptr |
| | pointer to mapped shared memory.
|
| |
| int | _fd = -1 |
| | shared memory file descriptor.
|
| |
◆ SharedMemory()
| join::SharedMemory::SharedMemory |
( |
const std::string & | name, |
|
|
uint64_t | size ) |
|
inline |
create instance.
- Parameters
-
| name | shared memory name. |
| size | shared memory size. |
◆ ~SharedMemory()
| virtual join::SharedMemory::~SharedMemory |
( |
| ) |
|
|
inlinevirtual |
◆ close()
| virtual void join::SharedMemory::close |
( |
| ) |
|
|
inlinevirtualnoexcept |
◆ get() [1/2]
| virtual void * join::SharedMemory::get |
( |
uint64_t | offset = 0 | ) |
|
|
inlinevirtual |
get a pointer to the shared memory at a given offset.
- Parameters
-
| offset | byte offset from the start of the shared memory. |
- Returns
- pointer to the mapped memory at the specified offset, or nullptr if not opened.
- Exceptions
-
| std::out_of_range | if offset is out of bounds. |
Reimplemented in join::BasicQueue< Policy >.
◆ get() [2/2]
| virtual const void * join::SharedMemory::get |
( |
uint64_t | offset = 0 | ) |
const |
|
inlinevirtual |
get a const pointer to the shared memory at a given offset.
- Parameters
-
| offset | byte offset from the start of the shared memory. |
- Returns
- pointer to the mapped memory at the specified offset, or nullptr if not opened.
- Exceptions
-
| std::out_of_range | if offset is out of bounds. |
Reimplemented in join::BasicQueue< Policy >.
◆ open()
| virtual int join::SharedMemory::open |
( |
| ) |
|
|
inlinevirtual |
◆ opened()
| bool join::SharedMemory::opened |
( |
| ) |
const |
|
inlinenoexcept |
check if shared memory is opened.
- Returns
- true if opened, false otherwise.
◆ size()
| virtual uint64_t join::SharedMemory::size |
( |
| ) |
const |
|
inlinevirtualnoexcept |
◆ unlink()
| static int join::SharedMemory::unlink |
( |
const std::string & | name | ) |
|
|
inlinestaticnoexcept |
destroy synchronization primitives and unlink the shared memory segment.
- Parameters
-
| name | shared memory segment name. |
- Returns
- 0 on success, -1 on failure.
◆ _fd
| int join::SharedMemory::_fd = -1 |
|
protected |
shared memory file descriptor.
◆ _name
| std::string join::SharedMemory::_name |
|
protected |
◆ _ptr
| void* join::SharedMemory::_ptr = nullptr |
|
protected |
pointer to mapped shared memory.
◆ _size
| uint64_t join::SharedMemory::_size = 0 |
|
protected |
The documentation for this class was generated from the following file: