userver: concurrent::LazyValue< T > Class Template Reference
Loading...
Searching...
No Matches
concurrent::LazyValue< T > Class Template Referencefinal

#include <userver/concurrent/lazy_value.hpp>

Detailed Description

template<typename T>
class concurrent::LazyValue< T >

Lazy value computation with multiple consumers.

Definition at line 21 of file lazy_value.hpp.

Public Member Functions

 LazyValue (utils::move_only_function< T()> f)
 LazyValue (const LazyValue &)=delete
 LazyValue (LazyValue &&)=delete
LazyValue & operator= (const LazyValue &)=delete
LazyValue & operator= (LazyValue &&)=delete
const T & operator() ()
 Get an already calculated result or calculate it. It is guaranteed that f is called exactly once. Can be called concurrently from multiple coroutines.

Constructor & Destructor Documentation

◆ LazyValue()

template<typename T>
concurrent::LazyValue< T >::LazyValue ( utils::move_only_function< T()> f)
inlineexplicit

Definition at line 23 of file lazy_value.hpp.

Member Function Documentation

◆ operator()()

template<typename T>
const T & concurrent::LazyValue< T >::operator() ( )

Get an already calculated result or calculate it. It is guaranteed that f is called exactly once. Can be called concurrently from multiple coroutines.

Note
If f throws, it is not re-evaluated on subsequent calls (unlike with std::once_flag).
Exceptions
Anythingf throws.

Definition at line 51 of file lazy_value.hpp.


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