27 std::size_t Capacity = 256
30 static_assert(std::is_trivially_copyable_v<EventVariant>,
31 "IpcChannel EventVariant must be trivially copyable for zero-copy shared memory IPC.");
41 bool create(
const std::string& channelName)
noexcept
53 bool attach(
const std::string& channelName)
noexcept
66 bool bindRaw(
void* buffer,
bool isCreator =
true) noexcept
68 _queue.
bind(buffer, isCreator);
77 template <
typename EventType>
78 bool post(EventType&& event)
noexcept
80 return _queue.
tryPush(EventVariant{std::forward<EventType>(event)});
87 bool tryPop(EventVariant& outEvent)
noexcept
89 return _queue.
tryPop(outEvent);
97 template <
typename SinkType>
98 std::size_t
pumpInto(
const SinkType& sink, std::size_t maxEvents = 0)
100 std::size_t count = 0;
102 while (_queue.
tryPop(ev)) {
103 sink.post(std::move(ev));
105 if (maxEvents > 0 && count >= maxEvents) {
116 std::string name = _shm.
name();
129 [[nodiscard]]
bool empty() const noexcept
131 return _queue.
empty();
135 [[nodiscard]]
constexpr std::size_t
capacity() const noexcept
Non-allocating type-erased fat pointer handle for lock-free event posting.
Standard lifecycle events (QuitEvent, ErrorEvent, TimerEvent).
RAII wrapper for POSIX shared memory and Windows file mappings.
Lock-free multi-producer single-consumer queue located in shared memory.
High-level typed inter-process communication channel for Corium events. Encapsulates OS shared memory...
Definition IpcChannel.hpp:29
constexpr std::size_t capacity() const noexcept
Configured capacity of the channel.
Definition IpcChannel.hpp:135
bool attach(const std::string &channelName) noexcept
Attach to an existing shared memory channel as a client process.
Definition IpcChannel.hpp:53
bool empty() const noexcept
Check if channel is empty.
Definition IpcChannel.hpp:129
bool tryPop(EventVariant &outEvent) noexcept
Pop one event from the shared queue. Single-consumer safe.
Definition IpcChannel.hpp:87
bool post(EventType &&event) noexcept
Post an event into the shared memory queue for remote processes. Lock-free, zero-allocation,...
Definition IpcChannel.hpp:78
bool bindRaw(void *buffer, bool isCreator=true) noexcept
Bind channel directly to a raw memory buffer (e.g. multi-core embedded SRAM).
Definition IpcChannel.hpp:66
std::size_t pumpInto(const SinkType &sink, std::size_t maxEvents=0)
Drain incoming shared memory events into a target event sink.
Definition IpcChannel.hpp:98
ShmMpscQueue< EventVariant, Capacity > QueueType
Definition IpcChannel.hpp:34
bool isValid() const noexcept
Check if channel is open and valid.
Definition IpcChannel.hpp:123
bool create(const std::string &channelName) noexcept
Create a new shared memory channel as the host/creator process.
Definition IpcChannel.hpp:41
void unlink() noexcept
Destroy the channel and remove shared memory from OS.
Definition IpcChannel.hpp:113
Cross-platform zero-copy shared memory region wrapper. Manages OS-level shared memory allocation,...
Definition SharedMemory.hpp:60
const std::string & name() const noexcept
Name identifier of shared memory.
Definition SharedMemory.hpp:256
void close() noexcept
Close and unmap the shared memory segment.
Definition SharedMemory.hpp:209
void * data() noexcept
Raw pointer to mapped shared memory buffer.
Definition SharedMemory.hpp:243
bool isValid() const noexcept
Check if mapped region is valid.
Definition SharedMemory.hpp:250
static void unlink(const std::string &name) noexcept
Remove shared memory identifier from OS namespace (POSIX shm_unlink).
Definition SharedMemory.hpp:232
bool open(const std::string &name, std::size_t size, AccessMode mode=AccessMode::CreateOrOpen) noexcept
Create or attach to a shared memory region.
Definition SharedMemory.hpp:126
Lock-free, zero-allocation multi-producer single-consumer ring buffer layout for shared memory....
Definition ShmMpscQueue.hpp:28
void bind(void *mappedAddress, bool initializeMemory=false) noexcept
Bind to a mapped shared memory region.
Definition ShmMpscQueue.hpp:75
bool empty() const noexcept
Check if queue is currently empty.
Definition ShmMpscQueue.hpp:183
bool tryPush(U &&item) noexcept
Lock-free push into shared memory queue (multi-producer safe).
Definition ShmMpscQueue.hpp:114
static constexpr std::size_t requiredMemorySize() noexcept
Required byte size of the shared memory layout.
Definition ShmMpscQueue.hpp:93
bool tryPop(T &outItem) noexcept
Lock-free pop from shared memory queue (single-consumer safe).
Definition ShmMpscQueue.hpp:154
bool isValid() const noexcept
Validate that the mapped shared memory contains a compatible ShmMpscQueue header.
Definition ShmMpscQueue.hpp:99
Definition DomainSocket.hpp:35
std::variant< QuitEvent, TickEvent, UpdateEvent, ErrorEvent, SignalEvent > DefaultEvents
Default variant list of core Corium events.
Definition Events.hpp:62