OpenLexocad
28.0
|
Basic dispatcher implementation. More...
#include <entt.hpp>
Public Types | |
template<typename Event > | |
using | sink_type = typename signal_wrapper< Event >::sink_type |
Type of sink for the given event. More... | |
Public Member Functions | |
template<typename Event > | |
sink_type< Event > | sink () ENTT_NOEXCEPT |
Returns a sink object for the given event. More... | |
template<typename Event , typename... Args> | |
void | trigger (Args &&... args) |
Triggers an immediate event of the given type. More... | |
template<typename Event > | |
void | trigger (Event &&event) |
Triggers an immediate event of the given type. More... | |
template<typename Event , typename... Args> | |
void | enqueue (Args &&... args) |
Enqueues an event of the given type. More... | |
template<typename Event > | |
void | enqueue (Event &&event) |
Enqueues an event of the given type. More... | |
template<typename... Event> | |
void | discard () |
Discards all the events queued so far. More... | |
template<typename Event > | |
void | update () |
Delivers all the pending events of the given type. More... | |
void | update () const |
Delivers all the pending events. More... | |
Basic dispatcher implementation.
A dispatcher can be used either to trigger an immediate event or to enqueue events to be published all together once per tick.
Listeners are provided in the form of member functions. For each event of type Event
, listeners are such that they can be invoked with an argument of type const Event &
, no matter what the return type is.
The types of the instances are Class &
. Users must guarantee that the lifetimes of the objects overcome the one of the dispatcher itself to avoid crashes.
using entt::dispatcher::sink_type = typename signal_wrapper<Event>::sink_type |
Type of sink for the given event.
|
inline |
Discards all the events queued so far.
If no types are provided, the dispatcher will clear all the existing pools.
Event | Type of events to discard. |
|
inline |
Enqueues an event of the given type.
An event of the given type is queued. No listener is invoked. Use the update
member function to notify listeners when ready.
Event | Type of event to enqueue. |
Args | Types of arguments to use to construct the event. |
args | Arguments to use to construct the event. |
|
inline |
Enqueues an event of the given type.
An event of the given type is queued. No listener is invoked. Use the update
member function to notify listeners when ready.
Event | Type of event to enqueue. |
event | An instance of the given type of event. |
|
inline |
Returns a sink object for the given event.
A sink is an opaque object used to connect listeners to events.
The function type for a listener is:
The order of invocation of the listeners isn't guaranteed.
Event | Type of event of which to get the sink. |
|
inline |
Triggers an immediate event of the given type.
All the listeners registered for the given type are immediately notified. The event is discarded after the execution.
Event | Type of event to trigger. |
Args | Types of arguments to use to construct the event. |
args | Arguments to use to construct the event. |
|
inline |
Triggers an immediate event of the given type.
All the listeners registered for the given type are immediately notified. The event is discarded after the execution.
Event | Type of event to trigger. |
event | An instance of the given type of event. |
|
inline |
Delivers all the pending events of the given type.
This method is blocking and it doesn't return until all the events are delivered to the registered listeners. It's responsibility of the users to reduce at a minimum the time spent in the bodies of the listeners.
Event | Type of events to send. |
|
inline |
Delivers all the pending events.
This method is blocking and it doesn't return until all the events are delivered to the registered listeners. It's responsibility of the users to reduce at a minimum the time spent in the bodies of the listeners.