This class creates memory which is requested by the MemoryBlocks. Once the memory is available, this is announced to the blocks, so that they can consume the memory for their needs. When the Memory is release, the blocks will also called to handle this appropriately, e.g. calling the destructor of the underlying type. This class is an interface with some default behavior and needs an implementation for real memory supply, e.g. a PosixShmMemoryProvider.
More...
#include <iceoryx_posh/roudi/memory/memory_provider.hpp>
|
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, shm_open and mmap would need to be called in the implementation of this function. More...
|
|
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, shm_unlink and munmap would need to be called in the implementation of this function. More...
|
|
This class creates memory which is requested by the MemoryBlocks. Once the memory is available, this is announced to the blocks, so that they can consume the memory for their needs. When the Memory is release, the blocks will also called to handle this appropriately, e.g. calling the destructor of the underlying type. This class is an interface with some default behavior and needs an implementation for real memory supply, e.g. a PosixShmMemoryProvider.
◆ MemoryProvider()
- Note
- this is intentional not movable/copyable, since a pointer to the memory provider is registered at the RouDiMemoryManager and therefore an instance of a MemoryProvider must be pinned to memory
◆ addMemoryBlock()
◆ baseAddress()
cxx::optional< void * > iox::roudi::MemoryProvider::baseAddress |
( |
| ) |
const |
|
noexcept |
This function provides the base address of the created memory.
- Returns
- an optional pointer to the base address of the created memory if the memory is available, otherwise a cxx::nullopt_t
◆ create()
With this call the memory requested by the MemoryBlocks need to be created. The function should be called from a MemoryManager which handles one or more MemoryProvider.
- Returns
- an MemoryProviderError if memory allocation was not successful, otherwise success
◆ createMemory()
virtual cxx::expected< void *, MemoryProviderError > iox::roudi::MemoryProvider::createMemory |
( |
const uint64_t |
size, |
|
|
const uint64_t |
alignment |
|
) |
| |
|
protectedpure virtualnoexcept |
This function needs to be implemented to provide the actual memory, e.g. in case of POSIX SHM, shm_open and mmap would need to be called in the implementation of this function.
- Parameters
-
[in] | size | is the size in bytes for the requested memory, the size should already be calculated according to the alignment requirements |
[in] | alignment | the required alignment for the memory |
- Returns
- the pointer of the begin of the created memory or a MemoryProviderError if the memory could not be created
Implemented in iox::roudi::PosixShmMemoryProvider.
◆ destroy()
This function destroys the previously allocated memory. Before the destruction, all MemoryBlocks are requested to handle this appropriately, e.g. call the destructor of the underlying type. The function should be called from a MemoryManager which handles one or more MemoryProvider.
- Returns
- an error if memory destruction was not successful, otherwise success
◆ destroyMemory()
|
protectedpure virtualnoexcept |
This function needs to be implemented to free the actual memory, e.g. in case of POSIX SHM, shm_unlink and munmap would need to be called in the implementation of this function.
- Returns
- a MemoryProviderError if the destruction failed, otherwise success
Implemented in iox::roudi::PosixShmMemoryProvider.
◆ isAvailable()
bool iox::roudi::MemoryProvider::isAvailable |
( |
| ) |
const |
|
noexcept |
This function can be used to check if the requested memory is already available.
- Returns
- true if the requested memory is available, false otherwise
◆ isAvailableAnnounced()
bool iox::roudi::MemoryProvider::isAvailableAnnounced |
( |
| ) |
const |
|
noexcept |
This function can be used to check if the availability of the memory was announced to the MemoryBlocks.
- Returns
- true if the availability of the memory was announced to the MemoryBlocks, false otherwise
◆ segmentId()
cxx::optional< uint64_t > iox::roudi::MemoryProvider::segmentId |
( |
| ) |
const |
|
noexcept |
This function provides the segment id of the relocatable memory segment which is owned by the MemoryProvider.
- Returns
- an optional segment id for the created memory if the memory is available, otherwise cxx::nullopt_t
◆ size()
uint64_t iox::roudi::MemoryProvider::size |
( |
| ) |
const |
|
noexcept |
This function provides the size of the created memory.
- Returns
- the size of the created memory
The documentation for this class was generated from the following file: