-
#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¶
Methods¶
- 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 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 associatedFuture
.
-
FutureCallbackRegistration
ExecuteWhenNotNeeded(Callback&& callback) const; Registers a callback to be invoked when
result_needed()
becomesfalse
.
- 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).
Related Functions¶
-
void tensorstore::SetDeferredResult(const Promise<T>& promise,
U&& result); If
promise
does not already have a result set, sets its result toresult
and setspromise.result_needed() = false
.