#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 29 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) |
| Forwards new events from an concurrent::AsyncEventSource without replaying past events. | |
| template<typename Class> | |
| void | UpdateAndListen (utils::ResourceScopeStorage &scopes, Class *obj, std::string_view name, void(Class::*func)()) |
| void | SendEvent () |
Private Member Functions | |
| void | SendEvent (Args... args) const |
| void concurrent::ConflatedEventChannel::AddChannel | ( | concurrent::AsyncEventSource< Args... > & | channel | ) |
Forwards new events from an concurrent::AsyncEventSource without replaying past events.
Definition at line 79 of file conflated_event_channel.hpp.
| void concurrent::ConflatedEventChannel::UpdateAndListen | ( | utils::ResourceScopeStorage & | scopes, |
| 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.
Further updates are delivered after utils::ResourceScopeStorage::AfterConstruction, including those updates that arrived before it. Unsubscribe runs in utils::ResourceScopeStorage::BeforeDestruction.
| scopes | storage that owns the subscription lifetime. See where to obtain scopes. |
| obj | object on which to invoke the callback. |
| name | subscriber name. |
| func | member function to invoke. |
Definition at line 85 of file conflated_event_channel.hpp.