userver: concurrent::ConflatedEventChannel Class Reference
Loading...
Searching...
No Matches
concurrent::ConflatedEventChannel Class Reference

#include <userver/concurrent/conflated_event_channel.hpp>

Detailed Description

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 27 of file conflated_event_channel.hpp.

Inheritance diagram for concurrent::ConflatedEventChannel:

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>
void UpdateAndListen (utils::ResourceScopeStorage &scopes, Class *obj, std::string_view name, void(Class::*func)())
template<typename Class>
concurrent::AsyncEventSubscriberScope UpdateAndListen (Class *obj, std::string_view name, void(Class::*func)())
void SendEvent ()

Private Member Functions

void SendEvent (Args... args) const

Member Function Documentation

◆ AddChannel()

template<typename... Args>
void concurrent::ConflatedEventChannel::AddChannel ( concurrent::AsyncEventSource< Args... > & channel)

For convenient forwarding of events from other channels.

Definition at line 69 of file conflated_event_channel.hpp.

◆ UpdateAndListen() [1/2]

template<typename Class>
concurrent::AsyncEventSubscriberScope concurrent::ConflatedEventChannel::UpdateAndListen ( Class * obj,
std::string_view name,
void(Class::* func )() )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Deprecated
Use the overload that takes utils::ResourceScopeStorage.

Store the returned scope as a member and call Unsubscribe explicitly.

Definition at line 84 of file conflated_event_channel.hpp.

◆ UpdateAndListen() [2/2]

template<typename Class>
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.

Parameters
scopesstorage that owns the subscription lifetime. In a component constructor pass context.Scopes() or components::GetResourceScopes.

Definition at line 74 of file conflated_event_channel.hpp.


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