Skip to content

AFutureSet#

Manages multiple futures.

Header:#include <AUI/Thread/AThreadPool.h>
CMake:aui_link(my_target PUBLIC aui::core)

Detailed Description#

Experimental Feature

This API is experimental. Experimental APIs are likely to contain bugs, might be changed or removed in the future.

AFutureSet involves functions to efficiently manage multiple AFutures.

Guarantees that held futures will never be executed or be during execution after AAsyncHolder is destroyed.

Public Methods#

checkForExceptions#


void AFutureSet::checkForExceptions()

Find AFutures that encountered an exception. If such AFuture is found, AInvocationTargetException is thrown.

onAllComplete#


template<aui::invocable OnComplete >
void AFutureSet::onAllComplete(OnComplete&& onComplete)

Specifies a callback which will be called when all futures in future set would have the result.

Even if all tasks are already completed, it's guaranteed that your callback will be called.

The thread on which your callback will be called is undefined.

AFutureSet is not required to be alive when AFutures would potentially call onSuccess callback since a temporary object is created to keep track of the task completeness.

waitForAll#


void AFutureSet::waitForAll()

Wait for the result of every AFuture.