|
stlab 3.0.0
Modern, modular C++ algorithms, data structures, and concurrency primitives
|
Consumer side of a one-shot result (non-copyable T). More...
#include <future.hpp>
Public Types | |
| using | result_type |
| The type of the value this future holds. | |
Public Member Functions | |
| future (const future &)=delete | |
| future (future &&) noexcept=default | |
| auto | operator= (const future &) -> future &=delete |
| auto | operator= (future &&) noexcept -> future &=default |
| void | swap (future &x) noexcept |
| Exchanges the shared state with x. | |
| auto | valid () const -> bool |
| True if this future has an associated shared state. | |
| template<class F> | |
| auto | then (F &&f) && |
| Returns a future that completes with the result of f applied to this future's value (rvalue only). | |
Pipe operators (<tt>operator|</tt>, <tt>operator^</tt>) | |
| template<class F> | |
| auto | operator| (F &&f) && |
| Pipe operator: same as then(f). | |
| template<class E, class F> | |
| auto | then (E &&executor, F &&f) && |
| Returns a future that completes with the result of f on executor applied to this future's value. | |
| template<class F> | |
| auto | operator| (executor_task_pair< F > etp) && |
| Pipe operator: same as then(etp.executor(), etp.task()). | |
| template<class F> | |
| auto | recover (F &&f) && |
| Returns a future that completes with the result of f given this future (possibly in error state); default executor. | |
| template<class F> | |
| auto | operator^ (F &&f) && |
| Pipe operator: same as recover(f). | |
| template<class E, class F> | |
| auto | recover (E &&executor, F &&f) && |
| Returns a future that completes with the result of f given this future, run on executor. | |
| template<class F> | |
| auto | operator^ (executor_task_pair< F > etp) && |
| Pipe operator: same as recover(etp.executor(), etp.task()). | |
| void | detach () && |
| Drops this future without cancelling the associated task. | |
| template<class F> | |
| void | detach (F &&f) && |
| When this future completes (value or exception), invokes f with it and does not propagate further. | |
| template<class F> | |
| void | on_completion (F &&f) |
| Invokes f immediately when this future completes (value or exception). This consumes the continuation slot, the behavior of attaching a continuation after on_completion() is undefined. | |
| template<class E, class F> | |
| void | on_completion (E &&executor, F &&f) |
| Invokes f when this future completes (value or exception), on executor. This consumes the continuation slot, the behavior of attaching a continuation after on_completion() is undefined. | |
| void | reset () noexcept |
| Releases the shared state; valid() becomes false. | |
| auto | is_ready () const &-> bool |
| True if the result or exception is available. | |
| auto | get_try () &-> std::optional< T > |
| Moves out the value if ready, otherwise returns std::nullopt without changing the future. Rethrows the stored exception if the future failed. | |
| auto | get_ready () &&-> T |
| Moves out the value; rethrows the stored exception if the future failed. | |
| auto | exception () const &-> std::exception_ptr |
| Returns the stored exception, or a null exception_ptr if the future completed with a value. | |
Consumer side of a one-shot result (non-copyable T).
Use get_try() on a mutable lvalue to poll and extract the value, or get_ready() on an rvalue when ready. Extraction moves the stored value; const value extraction is not supported. then/recover are available only on rvalues.
|
inlinenodiscard |
Returns the stored exception, or a null exception_ptr if the future completed with a value.
|
inlinenodiscard |
Moves out the value; rethrows the stored exception if the future failed.
|
inlinenodiscard |
Moves out the value if ready, otherwise returns std::nullopt without changing the future. Rethrows the stored exception if the future failed.