AUI_THREADPOOL#
Executes following {} block asynchronously in the global thread pool. Unlike
AUI_THREADPOOL_X, does now allow to set lambda's capture. Lambda's capture is [=]
.
Header: | #include <AUI/Util/kAUI.h> |
CMake: | aui_link(my_target PUBLIC aui::core) |
Definition#
#define AUI_THREADPOOL AThreadPool::global() * [=]()
Detailed Description#
When AFuture
is destroyed, the corresponding AUI_THREADPOOL
task is either cancelled or removed from
the execution queue. Use AFutureSet or AAsyncHolder to keep multiple AFuture
Example without a return value:
auto task = AUI_THREADPOOL {
AThread::sleep(1000); // a long task
};
Example with a return value:
auto futureStatus = AUI_THREADPOOL {
int status;
...
AThread::sleep(1000); // a long task
...
return status;
};
int status = *futureStatus;
Lambda operators are supported:
auto futureStatus = AUI_THREADPOOL mutable noexcept {
int status;
...
AThread::sleep(1000); // a long task
...
return status;
};
int status = *futureStatus;
Examples#
examples/ui/views/src/ExampleWindow.cpp
Views Example - All-in-one views building example.
}
}),
_new<ASpacerExpanding>(),
},
AUI_DECLARATIVE_FOR(i, *state->colors, AWordWrappingLayout) {
return Horizontal {
_new<ALabel>(i.toString()) AUI_WITH_STYLE {
TextColor { i.readableBlackOrWhite() },
}
} AUI_WITH_STYLE {
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;