template <typename V = void, typename E = void>
class consumer
Defined at line 330 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
Consumes the result of an asynchronous task.
Instances of this class have single-ownership of a unique capability for
consuming the task's result. This capability can be exercised at most once.
Ownership of the capability is implicitly transferred away when the
task is canceled or converted to a promise.
See also |fpromise::bridge|.
See documentation of |fpromise::promise| for more information.
SYNOPSIS
|V| is the type of value produced when the task completes successfully.
Use |std::tuple
<Args
...>| if the task produces multiple values, such as
when you intend to bind the task's completer to a callback with multiple
arguments using |fpromise::completer::bind_tuple()|.
Defaults to |void|.
|E| is the type of error produced when the task completes with an error.
Defaults to |void|.
Public Methods
void consumer<V, E> ()
Defined at line 339 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
void consumer<V, E> (consumer<V, E> && other)
Defined at line 340 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
void ~consumer<V, E> ()
Defined at line 341 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
consumer<V, E> & operator= (consumer<V, E> && other)
Defined at line 343 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
bool operator bool ()
Returns true if this instance currently owns the unique capability for
consuming the result of the task upon its completion.
Defined at line 347 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
void cancel ()
Explicitly cancels the task, meaning that its result will never be consumed.
See |fpromise::bridge| for details about cancellation.
Defined at line 351 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
bool was_abandoned ()
Returns true if the associated |completer| has abandoned the task.
This method returns a snapshot of the current abandonment state.
Note that the task may be abandoned concurrently at any time.
Defined at line 359 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
promise_impl<typename bridge_state::promise_continuation> promise ()
Returns an unboxed promise which resumes execution once this task has
completed. If the task is abandoned by its completer, the promise
will not produce a result, thereby causing subsequent tasks associated
with the promise to also be abandoned and eventually destroyed if
they cannot make progress without the promised result.
Defined at line 369 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
promise_impl<typename bridge_state::promise_continuation> promise_or (result_type result_if_abandoned)
A variant of |promise()| that allows a default result to be provided when
the task is abandoned by its completer. Typically this is used to cause
the promise to return an error when the task is abandoned instead of
causing subsequent tasks associated with the promise to also be abandoned.
The state of |result_if_abandoned| determines the promise's behavior
in case of abandonment.
- |fpromise::result_state::ok|: Reports a successful result.
- |fpromise::result_state::error|: Reports a failure result.
- |fpromise::result_state::pending|: Does not report a result, thereby
causing subsequent tasks associated with the promise to also be
abandoned and eventually destroyed if they cannot make progress
without the promised result.
Defined at line 389 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
void consumer<V, E> (const consumer<V, E> & other)
Defined at line 396 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h
consumer<V, E> & operator= (const consumer<V, E> & other)
Defined at line 397 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h