-
#include "tensorstore/util/future.h" -
template <typename Callback,
typename PromiseValue,
typename... Futures>
FutureCallbackRegistration
tensorstore::Link(Callback&& callback,
Promise<PromiseValue> promise,
Futures&&... future); Creates a “link”, which ties a
promiseto one or morefutureobjects and acallback.While this link remains in effect, invokes:
callback(promise, ReadyFuture(future)...)when all of the futures become ready. Iffuture.ready()is true upon invocation of this function for allfutureobjects,callbackwill be invoked from the current thread before this function returns.Additionally, forcing the future associated with
promisewill result in all of thefutureobjects being forced.If
promise.result_needed()becomesfalse, the link is automatically removed.- Parameters:¶
- Callback &&callback¶
The function to be called when the
futureobjects are ready. This function will be invoked either from the current thread, before this function returns, or from the thread that causes the lastfutureto be ready. It must not throw exceptions, and in general it should not block or take a long time to execute. The return value is ignored.- Promise<PromiseValue> promise¶
The promise to be linked.
- Futures&&... future¶
The futures to be linked.
- Returns:¶
A FutureCallbackRegistration handle that can be used to remove this link.
Note
A common use case is to call
promise.SetResultwithin the callback function, but this is not required.