#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 promise to one or more future objects and a callback.

While this link remains in effect, invokes: callback(promise, ReadyFuture(future)...) when all of the futures become ready. If future.ready() is true upon invocation of this function for all future objects, callback will be invoked from the current thread before this function returns.

Additionally, forcing the future associated with promise will result in all of the future objects being forced.

If promise.result_needed() becomes false, the link is automatically removed.

Parameters:
Callback &&callback

The function to be called when the future objects are ready. This function will be invoked either from the current thread, before this function returns, or from the thread that causes the last future to 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.SetResult within the callback function, but this is not required.