MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Lila::EventBus Class Reference

Thread-safe event subscription and publishing system for Lila. More...

#include <EventBus.hpp>

+ Collaboration diagram for Lila::EventBus:

Public Member Functions

void subscribe (EventType type, const std::shared_ptr< Subscription > &subscriber)
 Subscribe to an event type with a Subscription object.
 
template<EventHandler Handler>
void subscribe (EventType type, Handler &&handler)
 Subscribe to an event type with a handler function.
 
void publish (const StreamEvent &event)
 Publish an event to all subscribers of its type.
 

Private Attributes

std::unordered_map< EventType, std::vector< std::weak_ptr< Subscription > > > m_subscribers
 Subscribers by event type.
 
std::mutex m_mutex
 Mutex for thread safety.
 

Detailed Description

Thread-safe event subscription and publishing system for Lila.

The EventBus allows components to subscribe to specific event types and receive notifications when those events are published. Supports both Subscription objects and simple handler functions.

Usage Example

// Subscribe with a handler function
bus.subscribe(EventType::EvalError, [](const StreamEvent& event) {
// Handle error event
});
// Subscribe with a Subscription object
class MySub : public Lila::Subscription { ... };
bus.subscribe(EventType::ClientConnected, std::make_shared<MySub>());
// Publish an event
bus.publish(StreamEvent{EventType::EvalSuccess});
Abstract base class for event subscriptions.
Definition EventBus.hpp:135
Represents a published event in the system.
Definition EventBus.hpp:121

Thread safety: All subscription and publishing operations are protected by a mutex.

Definition at line 180 of file EventBus.hpp.


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