#include "tensorstore/util/future.h"
template <typename T>
class [[nodiscard]] tensorstore::Promise;

“Producer” interface to a one-time channel.

Template Parameters:
typename T

Specifies the type of the value to be transmitted. The actual result value type is Result<std::remove_const_t<T>>.

Types

type result_type;

The result type transmitted by the channel.

using value_type = T;

The value type contained in the result type.

Constructors

Promise();

Constructs an null Promise.

Promise(Promise<U> x);

Constructs from a compatible Promise.

Methods

Promiseoperator=(Promise<U> x) noexcept;

Assigns from a compatible Promise.

void reset() noexcept;

Resets this Promise to be null. :post: null().

bool null() const noexcept;

Returns true if this Promise has no shared state.

bool ready() const noexcept;

Returns true if the result is ready.

bool result_needed() const noexcept;

Returns true if this future has not been cancelled.

std::add_lvalue_reference_t<result_type> raw_result() const;

Returns a reference to the result value stored in the shared state.

bool SetResult(U&&... u) const noexcept;

Sets the result if it has not already been set.

bool SetReady() const noexcept;

Marks result as ready without modifying it.

FutureCallbackRegistration
ExecuteWhenForced(Callback&callback) const;

Registers a callback to be invoked when Future::Force is called on an associated Future.

FutureCallbackRegistration
ExecuteWhenNotNeeded(Callback&callback) const;

Registers a callback to be invoked when result_needed() becomes false.

Future<T> future() const;

Returns an associated Future, if one can be obtained without affecting the value of result_needed() (which would violate an invariant).

void tensorstore::SetDeferredResult(const Promise<T>promise,
                                    
U&result);

If promise does not already have a result set, sets its result to result and sets promise.result_needed() = false.