#include <userver/engine/future.hpp>
std::future replacement for asynchronous tasks that works in pair with engine::Promise
engine::Future can only be used from coroutine threads.
Definition at line 51 of file future.hpp.
Public Member Functions | |
Future ()=default | |
Creates an Future without a valid state. | |
Future (const Future &)=delete | |
Future (Future &&) noexcept=default | |
Future & | operator= (const Future &)=delete |
Future & | operator= (Future &&) noexcept=default |
bool | valid () const noexcept |
Returns whether this Future holds a valid state. | |
T | get () |
Waits for value availability and retrieves it. | |
FutureStatus | wait () const |
Waits for value availability. | |
template<typename Rep , typename Period > | |
FutureStatus | wait_for (std::chrono::duration< Rep, Period > timeout) const |
Waits for value availability until the timeout expires or until the task is cancelled. | |
template<typename Clock , typename Duration > | |
FutureStatus | wait_until (std::chrono::time_point< Clock, Duration > until) const |
Waits for value availability until the deadline is reached or until the task is cancelled. | |
FutureStatus | wait_until (Deadline deadline) const |
Waits for value availability until the deadline is reached or until the task is cancelled. | |
T engine::Future< T >::get | ( | ) |
Waits for value availability and retrieves it.
WaitInterruptedException | if the current task has been cancelled in the process. |
std::future_error | if Future holds no state, if the Promise has been destroyed without setting a value or if the value has already been retrieved. |
Definition at line 189 of file future.hpp.
|
noexcept |
Returns whether this Future holds a valid state.
Definition at line 184 of file future.hpp.
FutureStatus engine::Future< T >::wait | ( | ) | const |
Waits for value availability.
FutureStatus::kReady
if the value is available. FutureStatus::kCancelled
if current task is being cancelled. std::future_error | if Future holds no state. |
Definition at line 195 of file future.hpp.
FutureStatus engine::Future< T >::wait_for | ( | std::chrono::duration< Rep, Period > | timeout | ) | const |
Waits for value availability until the timeout expires or until the task is cancelled.
FutureStatus::kReady
if the value is available. FutureStatus::kTimeout
if timeout
has expired. FutureStatus::kCancelled
if current task is being cancelled. std::future_error | if Future holds no state. |
Definition at line 202 of file future.hpp.
FutureStatus engine::Future< T >::wait_until | ( | Deadline | deadline | ) | const |
Waits for value availability until the deadline is reached or until the task is cancelled.
FutureStatus::kReady
if the value is available. FutureStatus::kTimeout
if deadline
was reached. FutureStatus::kCancelled
if current task is being cancelled. std::future_error | if Future holds no state. |
Definition at line 215 of file future.hpp.
FutureStatus engine::Future< T >::wait_until | ( | std::chrono::time_point< Clock, Duration > | until | ) | const |
Waits for value availability until the deadline is reached or until the task is cancelled.
FutureStatus::kReady
if the value is available. FutureStatus::kTimeout
if until
time point was reached. FutureStatus::kCancelled
if current task is being cancelled. std::future_error | if Future holds no state. |
Definition at line 209 of file future.hpp.
|
friend |
Definition at line 102 of file future.hpp.