Class EventBus

Nested Relationships

Nested Types

Class Documentation

class EventBus

Declaration: final

An owned named-event registry.

A bus separates registrations/lifecycle; it does not select a thread. Immediate dispatch runs on its producer’s thread. String/any payload consistency remains the application author’s contract. Typed channels isolate name/type identity and check payloads before callback entry, using the same persistent registration and optional delivery lifetime.

Public Types

using Callback = std::function<void(std::any)>
using Work = std::move_only_function<void()>
using Delivery = std::function<bool(Work)>
using ErrorHandler = std::function<void(std::exception_ptr)>

Public Functions

EventBus() = default
~EventBus()
EventBus(const EventBus&) = delete
EventBus &operator=(const EventBus&) = delete
Registration register_listener(const std::string &event, Callback callback, Delivery delivery = Delivery{}, ErrorHandler errors = ErrorHandler{})
void dispatch(const std::string &event, const std::any &payload)
template<::CE::Events::EventPayload Payload>
inline Registration register_listener(const ::CE::Events::EventChannel<Payload> &event, typename ::CE::Events::EventChannel<Payload>::Callback callback, Delivery delivery = Delivery{}, ErrorHandler errors = ErrorHandler{})
template<::CE::Events::EventPayload Payload, typename Value>
inline void dispatch(const ::CE::Events::EventChannel<Payload> &event, Value &&payload)

Requires: std::same_as<std::remove_cvref_t<Value>, Payload> && std::is_constructible_v<Payload, Value&&>

bool unregister_listener(const Registration &registration)
void wait_for_listener(const Registration &registration) const
bool unregister_and_wait(const Registration &registration)
void close()
::CE::Events::EventStats diagnostics() const

Declaration: [[nodiscard]]

void report_diagnostics() const noexcept