Template Class ChunkSender

Inheritance Relationships

Base Type

Class Documentation

template<typename ChunkSenderDataType>
class ChunkSender : public iox::popo::ChunkDistributor<ChunkSenderDataType::ChunkDistributorData_t>

The ChunkSender is a building block of the shared memory communication infrastructure. It extends the functionality of a ChunkDistributor with the abililty to allocate and free memory chunks. For getting chunks of memory the MemoryManger is used. Together with the ChunkReceiver, they are the next abstraction layer on top of ChunkDistributor and ChunkQueuePopper. The ChunkSender holds the ownership of the SharedChunks and does a bookkeeping which chunks are currently passed to the user side.

Public Types

using MemberType_t = ChunkSenderDataType
using Base_t = ChunkDistributor<typename ChunkSenderDataType::ChunkDistributorData_t>

Public Functions

explicit ChunkSender(cxx::not_null<MemberType_t*const> chunkSenderDataPtr) noexcept
ChunkSender(const ChunkSender &other) = delete
ChunkSender &operator=(const ChunkSender&) = delete
ChunkSender(ChunkSender &&rhs) noexcept = default
ChunkSender &operator=(ChunkSender &&rhs) noexcept = default
~ChunkSender() noexcept = default
cxx::expected<mepoo::ChunkHeader*, AllocationError> tryAllocate(const UniquePortId originId, const uint32_t userPayloadSize, const uint32_t userPayloadAlignment, const uint32_t userHeaderSize, const uint32_t userHeaderAlignment) noexcept

allocate a chunk, the ownership of the SharedChunk remains in the ChunkSender for being able to cleanup if the user process disappears

Parameters:
  • originId, the[in] unique id of the entity which requested this allocate

  • userPayloadSize, size[in] of the user-payload without additional headers

  • userPayloadAlignment, alignment[in] of the user-payload

  • userHeaderSize, size[in] of the user-header; use iox::CHUNK_NO_USER_HEADER_SIZE to omit a user-header

  • userHeaderAlignment, alignment[in] of the user-header; use iox::CHUNK_NO_USER_HEADER_ALIGNMENT to omit a user-header

Returns:

on success pointer to a ChunkHeader which can be used to access the chunk-header, user-header and user-payload fields, error if not

void release(const mepoo::ChunkHeader *const chunkHeader) noexcept

Release an allocated chunk without sending it.

Parameters:

chunkHeader, pointer[in] to the ChunkHeader to release

uint64_t send(mepoo::ChunkHeader *const chunkHeader) noexcept

Send an allocated chunk to all connected ChunkQueuePopper.

Parameters:

chunkHeader, pointer[in] to the ChunkHeader to send; the ownership of the pointer is transferred to this method

Returns:

the number of receiver the chunk was send to

bool sendToQueue(mepoo::ChunkHeader *const chunkHeader, const cxx::UniqueId uniqueQueueId, const uint32_t lastKnownQueueIndex) noexcept

Send an allocated chunk to a specific ChunkQueuePopper.

Note

This method does not add the chunk to the history

Parameters:
  • chunkHeader, pointer[in] to the ChunkHeader to send; the ownership of the pointer is transferred to this method

  • uniqueQueueId[in] is an unique ID which identifies the queue to which this chunk shall be delivered

  • lastKnownQueueIndex[in] is used for a fast lookup of the queue with uniqueQueueId

Returns:

true when successful, false otherwise

void pushToHistory(mepoo::ChunkHeader *const chunkHeader) noexcept

Push an allocated chunk to the history without sending it.

Parameters:

chunkHeader, pointer[in] to the ChunkHeader to push to the history

cxx::optional<const mepoo::ChunkHeader*> tryGetPreviousChunk() const noexcept

Returns the last sent chunk if there is one.

Returns:

pointer to the ChunkHeader of the last sent Chunk if there is one, empty optional if not

void releaseAll() noexcept

Release all the chunks that are currently held. Caution: Only call this if the user process is no more running E.g. This cleans up chunks that were held by a user process that died unexpectetly, for avoiding lost chunks in the system.