Class SharedMemory

Class Documentation

class SharedMemory

Creates a bare metal shared memory object with the posix functions shm_open, shm_unlink etc. It must be used in combination with MemoryMap (or manual mmap calls)

Public Types

using Name_t = cxx::string<NAME_SIZE>

Public Functions

SharedMemory(const SharedMemory&) = delete
SharedMemory &operator=(const SharedMemory&) = delete
SharedMemory(SharedMemory&&) noexcept
SharedMemory &operator=(SharedMemory&&) noexcept
~SharedMemory() noexcept
int32_t getHandle() const noexcept

returns the file handle of the shared memory

bool hasOwnership() const noexcept

this class has the ownership of the shared memory when the shared memory was created by this class. This is the case when this class was successful created with EXCLUSIVE_CREATE, PURGE_AND_CREATE or OPEN_OR_CREATE and the shared memory was created. If an already available shared memory is opened then this class does not have the ownership.

Public Static Functions

static cxx::expected<bool, SharedMemoryError> unlinkIfExist(const Name_t &name) noexcept

removes shared memory with a given name from the system

Parameters:

name[in] name of the shared memory

Returns:

true if the shared memory was removed, false if the shared memory did not exist and SharedMemoryError when the underlying shm_unlink call failed.

Public Static Attributes

static constexpr uint64_t NAME_SIZE = platform::IOX_MAX_SHM_NAME_LENGTH
static constexpr int INVALID_HANDLE = -1

Friends

friend class SharedMemoryBuilder