userver: engine::TaskInheritedVariable< T > Class Template Reference
Loading...
Searching...
No Matches
engine::TaskInheritedVariable< T > Class Template Referencefinal

#include <userver/engine/task/inherited_variable.hpp>

Detailed Description

template<typename T>
class engine::TaskInheritedVariable< T >

TaskInheritedVariable is a per-coroutine variable of arbitrary type.

These are like engine::TaskLocalVariable, but the variable instances are inherited by child tasks created via utils::Async.

The order of destruction of task-inherited variables is unspecified.

Definition at line 24 of file inherited_variable.hpp.

Public Member Functions

const T * GetOptional () const noexcept
 Get the variable instance for the current task.
 
const T & Get () const
 Get the variable instance for the current task.
 
template<typename... Args>
void Emplace (Args &&... args)
 Sets or replaces the T variable instance.
 
void Set (T &&value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void Set (const T &value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void Erase ()
 Hide the variable so that it is no longer accessible from the current or new child tasks.
 

Member Function Documentation

◆ Emplace()

template<typename T >
template<typename... Args>
void engine::TaskInheritedVariable< T >::Emplace ( Args &&... args)
inline

Sets or replaces the T variable instance.

Definition at line 39 of file inherited_variable.hpp.

◆ Erase()

template<typename T >
void engine::TaskInheritedVariable< T >::Erase ( )
inline

Hide the variable so that it is no longer accessible from the current or new child tasks.

Note
The variable might not actually be destroyed immediately.

Definition at line 52 of file inherited_variable.hpp.

◆ Get()

template<typename T >
const T & engine::TaskInheritedVariable< T >::Get ( ) const
inline

Get the variable instance for the current task.

Exceptions
std::runtime_errorif variable was not set.

Definition at line 35 of file inherited_variable.hpp.

◆ GetOptional()

template<typename T >
const T * engine::TaskInheritedVariable< T >::GetOptional ( ) const
inlinenoexcept

Get the variable instance for the current task.

Returns
the variable or nullptr if variable was not set.

Definition at line 31 of file inherited_variable.hpp.

◆ Set() [1/2]

template<typename T >
void engine::TaskInheritedVariable< T >::Set ( const T & value)
inline

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

Definition at line 47 of file inherited_variable.hpp.

◆ Set() [2/2]

template<typename T >
void engine::TaskInheritedVariable< T >::Set ( T && value)
inline

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

Definition at line 44 of file inherited_variable.hpp.


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