Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::ipc::IpcChannel< EventVariant, Capacity > Class Template Reference

High-level typed inter-process communication channel for Corium events. Encapsulates OS shared memory allocation and lock-free event dispatching. More...

#include <IpcChannel.hpp>

+ Collaboration diagram for corium::ipc::IpcChannel< EventVariant, Capacity >:

Public Types

using QueueType = ShmMpscQueue< EventVariant, Capacity >
 

Public Member Functions

bool attach (const std::string &channelName) noexcept
 Attach to an existing shared memory channel as a client process.
 
bool bindRaw (void *buffer, bool isCreator=true) noexcept
 Bind channel directly to a raw memory buffer (e.g. multi-core embedded SRAM).
 
constexpr std::size_t capacity () const noexcept
 Configured capacity of the channel.
 
bool create (const std::string &channelName) noexcept
 Create a new shared memory channel as the host/creator process.
 
bool empty () const noexcept
 Check if channel is empty.
 
 IpcChannel ()=default
 
bool isValid () const noexcept
 Check if channel is open and valid.
 
template<typename EventType >
bool post (EventType &&event) noexcept
 Post an event into the shared memory queue for remote processes. Lock-free, zero-allocation, multi-producer safe.
 
template<typename SinkType >
std::size_t pumpInto (const SinkType &sink, std::size_t maxEvents=0)
 Drain incoming shared memory events into a target event sink.
 
bool tryPop (EventVariant &outEvent) noexcept
 Pop one event from the shared queue. Single-consumer safe.
 
void unlink () noexcept
 Destroy the channel and remove shared memory from OS.
 

Detailed Description

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
class corium::ipc::IpcChannel< EventVariant, Capacity >

High-level typed inter-process communication channel for Corium events. Encapsulates OS shared memory allocation and lock-free event dispatching.

Template Parameters
EventVariantSupported event variant list (must be trivially copyable or POD).
CapacityRing buffer capacity (power of 2, default 256).

Member Typedef Documentation

◆ QueueType

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
using corium::ipc::IpcChannel< EventVariant, Capacity >::QueueType = ShmMpscQueue<EventVariant, Capacity>

Constructor & Destructor Documentation

◆ IpcChannel()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
corium::ipc::IpcChannel< EventVariant, Capacity >::IpcChannel ( )
default

Member Function Documentation

◆ attach()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
bool corium::ipc::IpcChannel< EventVariant, Capacity >::attach ( const std::string &  channelName)
inlinenoexcept

Attach to an existing shared memory channel as a client process.

Parameters
channelNameUnique system name.
Returns
true on success, false otherwise.
+ Here is the call graph for this function:

◆ bindRaw()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
bool corium::ipc::IpcChannel< EventVariant, Capacity >::bindRaw ( void *  buffer,
bool  isCreator = true 
)
inlinenoexcept

Bind channel directly to a raw memory buffer (e.g. multi-core embedded SRAM).

Parameters
bufferPointer to raw memory region.
isCreatorIf true, initializes queue headers; if false, attaches to existing queue.
Returns
true if valid, false if buffer is null.
+ Here is the call graph for this function:

◆ capacity()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
constexpr std::size_t corium::ipc::IpcChannel< EventVariant, Capacity >::capacity ( ) const
inlineconstexprnoexcept

Configured capacity of the channel.

◆ create()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
bool corium::ipc::IpcChannel< EventVariant, Capacity >::create ( const std::string &  channelName)
inlinenoexcept

Create a new shared memory channel as the host/creator process.

Parameters
channelNameUnique system name (e.g. "/corium_robot_telemetry").
Returns
true on success, false otherwise.
+ Here is the call graph for this function:

◆ empty()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
bool corium::ipc::IpcChannel< EventVariant, Capacity >::empty ( ) const
inlinenoexcept

Check if channel is empty.

+ Here is the call graph for this function:

◆ isValid()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
bool corium::ipc::IpcChannel< EventVariant, Capacity >::isValid ( ) const
inlinenoexcept

Check if channel is open and valid.

+ Here is the call graph for this function:

◆ post()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
template<typename EventType >
bool corium::ipc::IpcChannel< EventVariant, Capacity >::post ( EventType &&  event)
inlinenoexcept

Post an event into the shared memory queue for remote processes. Lock-free, zero-allocation, multi-producer safe.

Template Parameters
EventTypeStrongly-typed event type.
Parameters
eventEvent payload.
Returns
true if pushed, false if shared queue is full.
+ Here is the call graph for this function:

◆ pumpInto()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
template<typename SinkType >
std::size_t corium::ipc::IpcChannel< EventVariant, Capacity >::pumpInto ( const SinkType &  sink,
std::size_t  maxEvents = 0 
)
inline

Drain incoming shared memory events into a target event sink.

Template Parameters
SinkTypeTarget EventSink or compatible sink.
Parameters
sinkTarget sink instance.
maxEventsMaximum events to drain (0 = drain all pending).
Returns
Number of events successfully transferred into local runtime.
+ Here is the call graph for this function:

◆ tryPop()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
bool corium::ipc::IpcChannel< EventVariant, Capacity >::tryPop ( EventVariant &  outEvent)
inlinenoexcept

Pop one event from the shared queue. Single-consumer safe.

Parameters
outEventReference populated with popped event variant.
Returns
true if an event was popped, false if queue is empty.
+ Here is the call graph for this function:

◆ unlink()

template<typename EventVariant = DefaultEvents, std::size_t Capacity = 256>
void corium::ipc::IpcChannel< EventVariant, Capacity >::unlink ( )
inlinenoexcept

Destroy the channel and remove shared memory from OS.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: