17#ifndef IOX_POSH_ROUDI_MEMORY_MEMORY_PROVIDER_HPP
18#define IOX_POSH_ROUDI_MEMORY_MEMORY_PROVIDER_HPP
20#include "iceoryx_posh/iceoryx_posh_types.hpp"
22#include "iceoryx_hoofs/cxx/expected.hpp"
23#include "iceoryx_hoofs/cxx/helplets.hpp"
24#include "iceoryx_hoofs/cxx/optional.hpp"
25#include "iceoryx_hoofs/cxx/vector.hpp"
70 friend class RouDiMemoryManager;
73 MemoryProvider()
noexcept =
default;
74 virtual ~MemoryProvider()
noexcept;
79 MemoryProvider(MemoryProvider&&) =
delete;
80 MemoryProvider& operator=(
const MemoryProvider&) =
delete;
81 MemoryProvider& operator=(MemoryProvider&&) =
delete;
87 cxx::expected<MemoryProviderError>
addMemoryBlock(cxx::not_null<MemoryBlock*> memoryBlock)
noexcept;
92 cxx::expected<MemoryProviderError>
create() noexcept;
111 uint64_t
size() const noexcept;
135 const uint64_t alignment) noexcept = 0;
145 void* m_memory{
nullptr};
147 uint64_t m_segmentId{0};
148 bool m_memoryAvailableAnnounced{
false};
149 cxx::vector<MemoryBlock*, MAX_NUMBER_OF_MEMORY_BLOCKS_PER_MEMORY_PROVIDER> m_memoryBlocks;
The MemoryBlock is a container for general purpose memory. It is used to request some memory from a M...
Definition memory_block.hpp:34
virtual cxx::expected< void *, MemoryProviderError > createMemory(const uint64_t size, const uint64_t alignment) noexcept=0
This function needs to be implemented to provide the actual memory, e.g. in case of POSIX SHM,...
bool isAvailableAnnounced() const noexcept
This function can be used to check if the availability of the memory was announced to the MemoryBlock...
cxx::expected< MemoryProviderError > addMemoryBlock(cxx::not_null< MemoryBlock * > memoryBlock) noexcept
This function add a MemoryBlock to the list of memory requester.
uint64_t size() const noexcept
This function provides the size of the created memory.
virtual cxx::expected< MemoryProviderError > destroyMemory() noexcept=0
This function needs to be implemented to free the actual memory, e.g. in case of POSIX SHM,...
cxx::optional< uint64_t > segmentId() const noexcept
This function provides the segment id of the relocatable memory segment which is owned by the MemoryP...
void announceMemoryAvailable() noexcept
This function announces the availability of the memory to the MemoryBlocks. The function should be ca...
bool isAvailable() const noexcept
This function can be used to check if the requested memory is already available.
cxx::optional< void * > baseAddress() const noexcept
This function provides the base address of the created memory.
cxx::expected< MemoryProviderError > create() noexcept
With this call the memory requested by the MemoryBlocks need to be created. The function should be ca...
MemoryProvider(const MemoryProvider &)=delete
cxx::expected< MemoryProviderError > destroy() noexcept
This function destroys the previously allocated memory. Before the destruction, all MemoryBlocks are ...
Definition iceoryx_posh_types.hpp:217
MemoryProviderError
Definition memory_provider.hpp:36
@ MEMORY_DEALLOCATION_FAILED
memory destruction failed at deallocating memory
Definition memory_provider.hpp:56
@ MEMORY_DESTRUCTION_FAILED
generic error if memory destruction failed
Definition memory_provider.hpp:54
@ MEMORY_ALIGNMENT_EXCEEDS_PAGE_SIZE
attempt to create memory with an alignment bigger than the page size
Definition memory_provider.hpp:46
@ MEMORY_CREATION_FAILED
generic error if memory creation failed
Definition memory_provider.hpp:44
@ MEMORY_ALREADY_CREATED
attempt to create memory although it already was created
Definition memory_provider.hpp:42
@ MEMORY_BLOCKS_EXHAUSTED
attempt to add more memory blocks than the capacity allows
Definition memory_provider.hpp:38
@ MEMORY_UNMAPPING_FAILED
memory destruction failed at unmapping memory
Definition memory_provider.hpp:58
@ NO_MEMORY_BLOCKS_PRESENT
an action was performed which requires memory blocks
Definition memory_provider.hpp:40
@ MEMORY_ALLOCATION_FAILED
memory creation failed at allocating memory
Definition memory_provider.hpp:48
@ MEMORY_NOT_AVAILABLE
an action was performed which requires memory
Definition memory_provider.hpp:52
@ MEMORY_MAPPING_FAILED
memory creation failed at mapping memory
Definition memory_provider.hpp:50
@ SIGACTION_CALL_FAILED
Setup or teardown of SIGBUS failed.
Definition memory_provider.hpp:60