35 template <
typename Event>
36 void push(
const Event& event,
int priority = 0) {
37 entries_.push_back({priority, [event](
EventBus& bus) { bus.publish(event); }});
45 std::ranges::stable_sort(
46 entries_, [](
const Entry& a,
const Entry& b) {
return a.priority > b.priority; });
47 for (
const Entry& entry : entries_) {
55 [[nodiscard]] std::size_t
size() const noexcept {
return entries_.size(); }
58 void clear() noexcept { entries_.clear(); }
66 std::vector<Entry> entries_;
Lets systems react to events without knowing who sends them.
Definition event_bus.hpp:31
Deferred event queue dispatched by priority at a chosen point in the tick.
Definition event_queue.hpp:30
void clear() noexcept
Discards all queued events without dispatching them.
Definition event_queue.hpp:58
std::size_t size() const noexcept
Number of events currently in the queue.
Definition event_queue.hpp:55
void push(const Event &event, int priority=0)
Queues an event for deferred dispatch.
Definition event_queue.hpp:36
void dispatch(EventBus &bus)
Dispatches all queued events in priority order and clears the queue.
Definition event_queue.hpp:44
Typed publish/subscribe event bus with immediate dispatch.
Logging, time, main loop, events and configuration shared by client and server.
Definition clock.hpp:11