A one-to-one provider for a single value.
An ValueProvider can only vend one ValueFuture at a time.
This provider is multi-shot: after Resolve is called, a new future can be retrieved with Get to wait for the next Resolve event.
ValueProvider must resolve its future, if any, before it is destroyed. OptionalValueProvider, in contrast, supports cancelling its future.
| T | The type of value to provide. |
Public Member Functions | |
| ValueProvider (ValueProvider &&other) noexcept | |
| ValueProvider & | operator= (ValueProvider &&other) noexcept |
| ValueProvider (const ValueProvider &)=delete | |
| ValueProvider & | operator= (const ValueProvider &)=delete |
| ValueFuture< T > | Get () |
| std::optional< ValueFuture< T > > | TryGet () |
| bool | has_future () const |
Returns true if the provider stores a pending future. | |
| template<typename... Args, typename U = T, std::enable_if_t<!std::is_void_v< U >, int > = 0> | |
| void | Resolve (Args &&... args) |
| template<typename U = T, std::enable_if_t< std::is_void_v< U >, int > = 0> | |
| void | Resolve () |
Resolves the pending ValueFuture. | |
|
inline |
Returns a ValueFuture that will be completed when Resolve is called.
If a future has already been vended and is still pending, this crashes.
|
inline |
Resolves the pending ValueFuture, if any, by constructing its value in-place.
|
inline |
Returns a ValueFuture that will be completed when Resolve is called.
If a future has already been vended and is still pending, this will return std::nullopt.