Skip to content

iox::roudi::MemoryBlock🔗

The MemoryBlock is a container for general purpose memory. It is used to request some memory from a MemoryProvider, which can be POSIX SHM, the stack or something completely different. To be able to use the container, some functions need to be implemented. For most use cases the GenericMemoryBlock can be used, which is a templated class and implements the most common case.

#include <memory_block.hpp>

Inherited by iox::roudi::GenericMemoryBlock< T >, iox::roudi::MemPoolCollectionMemoryBlock, iox::roudi::MemPoolSegmentManagerMemoryBlock, iox::roudi::PortPoolMemoryBlock

Public Functions🔗

Name
MemoryBlock() =default
MemoryBlock(const MemoryBlock & )
MemoryBlock(MemoryBlock && )
MemoryBlock & operator=(const MemoryBlock & )
MemoryBlock & operator=(MemoryBlock && )
virtual uint64_t size() const =0
This function provides the size of the required memory for the underlying data. It is needed for the MemoryProvider to calculate the total size of memory.
virtual uint64_t alignment() const =0
This function provides the alignment of the memory for the underlying data. This information is needed for the MemoryProvider.
virtual void destroy() =0
The MemoryProvider calls this either when MemoryProvider::destroy is called or in its destructor.
virtual void memoryAvailable(void * memory)
This function is called once the memory is available and is therefore the earliest possibility to use the memory.
cxx::optional< void * > memory() const
This function provides the pointer to the requested memory.

Friends🔗

Name
class MemoryProvider

Public Functions Documentation🔗

function MemoryBlock🔗

MemoryBlock() =default

function MemoryBlock🔗

MemoryBlock(
    const MemoryBlock & 
)

Note: this is intentional not movable/copyable, since a pointer to the memory block is registered at a MemoryProvider and therefore an instance of a MemoryBlock must be pinned to memory

function MemoryBlock🔗

MemoryBlock(
    MemoryBlock && 
)

function operator=🔗

MemoryBlock & operator=(
    const MemoryBlock & 
)

function operator=🔗

MemoryBlock & operator=(
    MemoryBlock && 
)

function size🔗

virtual uint64_t size() const =0

This function provides the size of the required memory for the underlying data. It is needed for the MemoryProvider to calculate the total size of memory.

Return: the required memory as multiple of the alignment

Reimplemented by: iox::roudi::PortPoolMemoryBlock::size, iox::roudi::MemPoolSegmentManagerMemoryBlock::size, iox::roudi::GenericMemoryBlock::size, iox::roudi::MemPoolCollectionMemoryBlock::size

function alignment🔗

virtual uint64_t alignment() const =0

This function provides the alignment of the memory for the underlying data. This information is needed for the MemoryProvider.

Return: the alignment of the underlying data.

Reimplemented by: iox::roudi::PortPoolMemoryBlock::alignment, iox::roudi::MemPoolSegmentManagerMemoryBlock::alignment, iox::roudi::GenericMemoryBlock::alignment, iox::roudi::MemPoolCollectionMemoryBlock::alignment

function destroy🔗

virtual void destroy() =0

The MemoryProvider calls this either when MemoryProvider::destroy is called or in its destructor.

Note: This function can be called multiple times. Make sure that the implementation can handle this.

Reimplemented by: iox::roudi::GenericMemoryBlock::destroy, iox::roudi::PortPoolMemoryBlock::destroy, iox::roudi::MemPoolSegmentManagerMemoryBlock::destroy, iox::roudi::MemPoolCollectionMemoryBlock::destroy

function memoryAvailable🔗

virtual void memoryAvailable(
    void * memory
)

This function is called once the memory is available and is therefore the earliest possibility to use the memory.

Parameters:

  • memory pointer to a valid memory block, the same one that the memory() member function would return

Reimplemented by: iox::roudi::PortPoolMemoryBlock::memoryAvailable, iox::roudi::MemPoolSegmentManagerMemoryBlock::memoryAvailable, iox::roudi::MemPoolCollectionMemoryBlock::memoryAvailable

function memory🔗

cxx::optional< void * > memory() const

This function provides the pointer to the requested memory.

Return: an optional pointer to a memory block with the requested size and alignment if the memory is available, otherwise a cxx::nullopt_t

Friends🔗

friend MemoryProvider🔗

friend class MemoryProvider;

Updated on 26 April 2021 at 15:31:02 CEST