template <typename V = void, typename E = void>

class completer

Defined at line 191 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

Provides a result upon completion of an asynchronous task.

Instances of this class have single-ownership of a unique capability for

completing the task. This capability can be exercised at most once.

Ownership of the capability is implicitly transferred away when the

completer is abandoned, completed, or bound to a callback.

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 completer<V, E> ()

Defined at line 200 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

void completer<V, E> (completer<V, E> && other)

Defined at line 201 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

void ~completer<V, E> ()

Defined at line 202 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

completer<V, E> & operator= (completer<V, E> && other)

Defined at line 204 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

reporting completion of the task.

Defined at line 208 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

bool was_canceled ()

Returns true if the associated |consumer| has canceled the task.

This method returns a snapshot of the current cancellation state.

Note that the task may be canceled concurrently at any time.

Defined at line 213 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

void abandon ()

Explicitly abandons the task, meaning that it will never be completed.

See |fpromise::bridge| for details about abandonment.

Defined at line 220 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

template <typename VV = value_type, typename = std::enable_if_t<std::is_void_v<VV>>>
void complete_ok ()

Reports that the task has completed successfully.

This method takes no arguments if |value_type| is void, otherwise it

takes one argument which must be assignable to |value_type|.

Defined at line 229 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

template <typename VV = value_type, typename = std::enable_if_t<!std::is_void_v<VV>>>
void complete_ok (VV value)

Defined at line 235 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

template <typename EE = error_type, typename = std::enable_if_t<std::is_void_v<EE>>>
void complete_error ()

Reports that the task has completed with an error.

This method takes no arguments if |error_type| is void, otherwise it

takes one argument which must be assignable to |error_type|.

Defined at line 246 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

template <typename EE = error_type, typename = std::enable_if_t<!std::is_void_v<EE>>>
void complete_error (EE error)

Defined at line 252 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

void complete_or_abandon (result_type result)

Reports that the task has completed or been abandoned.

See |fpromise::bridge| for details about abandonment.

The result state determines the task's final disposition.

- |fpromise::result_state::ok|: The task completed successfully.

- |fpromise::result_state::error|: The task completed with an error.

- |fpromise::result_state::pending|: The task was abandoned.

Defined at line 266 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

::fpromise::internal::bridge_bind_callback<V, E> bind ()

Returns a callback that reports completion of the asynchronous task along

with its result when invoked. This method is typically used to bind

completion of a task to a callback that has zero or one argument.

If |value_type| is void, the returned callback's signature is: void(void)

Otherwise, the returned callback's signature is: void(value_type).

The returned callback is thread-safe and move-only.

Defined at line 280 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

::fpromise::internal::bridge_bind_tuple_callback<V, E> bind_tuple ()

A variant of |bind()| that can be used to bind a completion of a task

to a callback that has zero or more arguments by wrapping the callback's

arguments into a tuple when producing the task's result.

The |value_type| must be a tuple type.

Given a |value_type| of std::tuple

<Args

...>, the returned callback's

signature is: void(Args...). Note that the tuple's fields are

unpacked as individual arguments of the callback.

The returned callback is thread-safe and move-only.

Defined at line 295 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

void completer<V, E> (const completer<V, E> & other)

Defined at line 300 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h

completer<V, E> & operator= (const completer<V, E> & other)

Defined at line 301 of file ../../sdk/lib/fit-promise/include/lib/fpromise/bridge.h