#include <userver/concurrent/conflated_event_channel.hpp>
A non-blocking version of 'AsyncEventChannel'.
The difference is that 'SendEvent' returns immediately, without waiting for subscribers to finish. If 'SendEvent' is called multiple times while subscribers are handling the previous event, new events will be conflated (all events except for the last one will be ignored). This class can be used instead of 'AsyncEventChannel' when we've got a "heavy" subscriber and we don't want to slow down the pipeline.
Definition at line 24 of file conflated_event_channel.hpp.
Public Member Functions | |
ConflatedEventChannel (std::string name, OnRemoveCallback on_listener_removal={}) | |
template<typename... Args> | |
void | AddChannel (concurrent::AsyncEventSource< Args... > &channel) |
For convenient forwarding of events from other channels. | |
template<typename Class > | |
concurrent::AsyncEventSubscriberScope | UpdateAndListen (Class *obj, std::string_view name, void(Class::*func)()) |
void | SendEvent () |
void concurrent::ConflatedEventChannel::AddChannel | ( | concurrent::AsyncEventSource< Args... > & | channel | ) |
For convenient forwarding of events from other channels.
Definition at line 56 of file conflated_event_channel.hpp.
concurrent::AsyncEventSubscriberScope concurrent::ConflatedEventChannel::UpdateAndListen | ( | Class * | obj, |
std::string_view | name, | ||
void(Class::*)() | func ) |
Subscribes to updates using a member function. Also immediately invokes the function with the current config snapshot.
Definition at line 63 of file conflated_event_channel.hpp.