LDA++
|
#include <Events.hpp>
Public Member Functions | |
virtual void | add_listener (std::shared_ptr< EventListenerInterface > listener) override |
virtual void | remove_listener (std::shared_ptr< EventListenerInterface > listener) override |
virtual void | dispatch (std::shared_ptr< Event > event) override |
void | process_events () |
Public Member Functions inherited from ldaplusplus::events::EventDispatcherInterface | |
std::shared_ptr< EventListenerInterface > | add_listener (std::function< void(std::shared_ptr< Event >)> listener) |
template<class ListenerType , typename... Args> | |
std::shared_ptr< EventListenerInterface > | add_listener (Args...args) |
template<class EventType , typename... Args> | |
void | dispatch (Args...args) |
A thread safe event dispatcher that dispatches the events when its process_events method is called and on the thread that the process_events method is called.
|
overridevirtual |
Add a listener to this dispatcher so that in subsequent calls to dispatch this listener will be notified.
The interface doesn't define handling of double adds or double removes.
listener | The listener to be added |
Implements ldaplusplus::events::EventDispatcherInterface.
|
overridevirtual |
Call the on_event() function of every listener passing this event as a parameter.
The interface doesn't define when the on_event function will be called and it is not guaranteed that upon return of the dispatch function all listeners will be notified.
event | The event to be sent to the listeners |
Implements ldaplusplus::events::EventDispatcherInterface.
Reimplemented in ldaplusplus::events::SameThreadEventDispatcher.
void ldaplusplus::events::ThreadSafeEventDispatcher::process_events | ( | ) |
Traverse the listener queue and notify them of any events that occured since the last time.
The listeners will be called on the thread that this method is called.
|
overridevirtual |
Remove a listener from this dispatcher so that in subsequent calls to dispatch this listener will not be notified.
The interface doesn't define handling of double adds or double removes.
listener | The listener to be removed |
Implements ldaplusplus::events::EventDispatcherInterface.