A generic provider that vends user-defined derived futures.
DerivedValueProvider allows attaching custom parameters to requests by using a class derived from ValueFuture. This enables the provider to inspect the parameters (e.g., requested size) and conditionally fulfill requests via ResolveIf.
| DerivedFuture | The user-defined future type. It must inherit from ValueFuture<T> and provide a constructor that accepts ValueFuture<T>&& as its first argument. |
Public Member Functions | |
| template<typename... Args> | |
| DerivedFuture | Get (Args &&... args) |
| Vends a derived future. | |
| template<typename... Args> | |
| std::optional< DerivedFuture > | TryGet (Args &&... args) |
| Vends a derived future if none is currently pending. | |
| template<typename F > | |
| bool | ResolveIf (F &&callback) |
|
inline |
Atomically inspects the derived future and resolves it if the callback returns a value indicating fulfillment.
The callback receives a reference to the DerivedFuture and should return a value indicating whether the request can be fulfilled:
T), the callback should return std::optional<T>. Returning std::nullopt leaves the future pending.bool. Returning false leaves the future pending.| callback | A callable (lambda, function pointer, etc.) invoked with a reference to the DerivedFuture. |
true if the future was resolved, false otherwise.