AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
ASharedRaiiHelper Class Reference

Shared completion marker for multithreaded callback-based future handling. More...

Detailed Description

Shared completion marker for multithreaded callback-based future handling.

ASharedRaiiHelper is intended to track the completion of multiple futures, exploiting the destruction of AFuture::onSuccess or AFuture::onError callbacks when they called. This approach allows to easily integrate ASharedRaiiHelper to the existing code.

Note that the callback will be called even if onSuccess is not.

auto marker = ASharedRaiiHelper::make([] {
// will be called when all futures called onSuccess or destroyed
});
auto future = async {
// hard work
}
// VVVVVV ASharedRaiiHelper should be captured!
future.onSuccess([this, marker]() {
// handle the hard work
});
// keep the future alive in async holder
mAsyncHolder << future;
#define async
Executes following {} block asynchronously in the global thread pool. Unlike asyncX,...
Definition: kAUI.h:329

Static Public Member Functions

static _< ASharedRaiiHelpermake (std::function< void()> callback)
 

#include <AUI/Util/ASharedRaiiHelper.h>


The documentation for this class was generated from the following file: