32 typename QueuePolicy = BoundedMpscQueuePolicy<EventVariantType, 1024>,
33 typename SignalPolicy = CallbackSignalPolicy,
35 typename OverflowPolicy = DropNewestOverflowPolicy
64 return _incomingBus.
sink();
70 return _context.mainSink();
74 template <
typename EventType,
typename Handler>
77 return _incomingBus.template registerHandler<EventType>(std::forward<Handler>(handler));
81 template <
typename Handler>
82 bool on(Handler&& handler)
98 std::size_t processed = 0;
108 std::size_t
pump(std::size_t maxEvents)
110 std::size_t processed = 0;
111 while (processed < maxEvents && _incomingBus.
processOne()) {
122 template <
typename EventType>
125 _context.mainSink().post(std::forward<EventType>(event), priority);
129 template <
typename EventType>
132 _context.mainSink().postHighPriority(std::forward<EventType>(event));
136 template <
typename TargetService,
typename EventType>
139 return _context.template sendToService<TargetService>(std::forward<EventType>(event), priority);
152template <
typename EventVariant = DefaultEvents>
163template <
typename EventVariant = DefaultEvents, std::
size_t Capacity = 64>
Multi-producer single-consumer lock-free event bus coordinator.
Non-allocating type-erased fat pointer handle for lock-free event posting.
Bounded and multi-tier priority MPSC queueing policies.
Dependency injection context for background services.
Thread wake-up policies (NoSignalPolicy, ConditionVariableSignalPolicy).
Static storage capacity policies for FastDelegate SBO inline buffers.
Policy-configurable non-virtual event bus implementation.
Definition EventBus.hpp:35
EventSinkT< EventVariant > sink() noexcept
Get an EventSink handle pointing to this event bus.
Definition EventBus.hpp:205
bool processOne()
Process a single event from the queue.
Definition EventBus.hpp:78
bool registerHandler(Handler &&handler)
Register an event handler with explicit event type parameter.
Definition EventBus.hpp:159
Queue Policy for fixed-capacity, zero-allocation lock-free MPSC RingBuffer.
Definition QueuePolicies.hpp:43
Signal Policy invoking an edge-triggered callback on 0->1 transition when queue becomes non-empty.
Definition SignalPolicies.hpp:91
Zero-overhead Queue Policy for services or buses that do not receive or queue incoming events....
Definition QueuePolicies.hpp:240
Signal Policy for busy-spin / polling event loops (sub-microsecond latency, zero signaling cost).
Definition SignalPolicies.hpp:72
Non-allocating base class for synchronous or thread-agnostic services. Provides event producing (post...
Definition Service.hpp:37
Service & operator=(const Service &)=delete
std::size_t pump(std::size_t maxEvents)
Pump up to maxEvents pending incoming events from the queue.
Definition Service.hpp:108
EventSinkT< EventVariant > mainSink() const noexcept
Get an EventSink handle targeting the main application event queue.
Definition Service.hpp:68
const ServiceContextT< EventVariant > & context() const noexcept
Definition Service.hpp:119
bool registerHandler(Handler &&handler)
Register an event handler for incoming events with explicit event type parameter.
Definition Service.hpp:75
Service(ServiceContextT< EventVariant > context)
Definition Service.hpp:44
void post(EventType &&event, EventPriority priority=EventPriority::Normal) const
Post an event into the main application event queue.
Definition Service.hpp:123
EventVariantType EventVariant
Definition Service.hpp:39
const IncomingBus & incomingBus() const noexcept
Definition Service.hpp:143
std::size_t pump()
Pump all pending incoming events from the queue until empty.
Definition Service.hpp:96
void setContext(ServiceContextT< EventVariant > context) noexcept
Definition Service.hpp:56
bool on(Handler &&handler)
Register an event handler for incoming events with automatic event type deduction.
Definition Service.hpp:82
IncomingBus & incomingBus() noexcept
Definition Service.hpp:142
bool processOne()
Process a single incoming event from the service queue.
Definition Service.hpp:89
EventSinkT< EventVariant > sink() noexcept
Get an EventSink handle targeting this service's incoming event queue.
Definition Service.hpp:62
Service(const Service &)=delete
BasicEventBus< EventVariant, QueuePolicy, SignalPolicy, StoragePolicy, OverflowPolicy > IncomingBus
Definition Service.hpp:40
ServiceContextT< EventVariant > & context() noexcept
Definition Service.hpp:118
void postHighPriority(EventType &&event) const
Post a high-priority event into the main application event queue.
Definition Service.hpp:130
bool sendToService(EventType &&event, EventPriority priority=EventPriority::Normal) const
Post an event directly to another registered service.
Definition Service.hpp:137
Service(Service &&) noexcept=default
Definition Application.hpp:16
std::variant< QuitEvent, TickEvent, UpdateEvent, ErrorEvent, SignalEvent > DefaultEvents
Default variant list of core Corium events.
Definition Events.hpp:62
EventPriority
Event priority levels for multi-priority queue policies.
Definition QueuePolicies.hpp:32
FixedStoragePolicy< 8, 32 > DefaultStoragePolicy
Default storage policy (8 handlers per event type, 32 bytes inline delegate storage).
Definition StoragePolicies.hpp:24
Policy configuring compile-time handler capacity and delegate inline storage size.
Definition StoragePolicies.hpp:18