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"
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;
This class creates memory which is requested by the MemoryBlocks. Once the memory is available,...
Definition memory_provider.hpp:69
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 roudi_memory_manager.hpp:53
MemoryProviderError
Definition memory_provider.hpp:36
@ MEMORY_DEALLOCATION_FAILED
memory destruction failed at deallocating memory
@ MEMORY_DESTRUCTION_FAILED
generic error if memory destruction failed
@ MEMORY_ALIGNMENT_EXCEEDS_PAGE_SIZE
attempt to create memory with an alignment bigger than the page size
@ MEMORY_CREATION_FAILED
generic error if memory creation failed
@ MEMORY_ALREADY_CREATED
attempt to create memory although it already was created
@ MEMORY_BLOCKS_EXHAUSTED
attempt to add more memory blocks than the capacity allows
@ MEMORY_UNMAPPING_FAILED
memory destruction failed at unmapping memory
@ NO_MEMORY_BLOCKS_PRESENT
an action was performed which requires memory blocks
@ MEMORY_ALLOCATION_FAILED
memory creation failed at allocating memory
@ MEMORY_NOT_AVAILABLE
an action was performed which requires memory
@ MEMORY_MAPPING_FAILED
memory creation failed at mapping memory
@ SIGACTION_CALL_FAILED
Setup or teardown of SIGBUS failed.