AThreadPool#
Thread pool implementation.
Header: | #include <AUI/Thread/AThreadPool.h> |
CMake: | aui_link(my_target PUBLIC aui::core) |
Examples#
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
connect(isRunning.changed, AUI_SLOT(mTimer)::setRunning);
}
void frame() {
mFrame = AThreadPool::global() * [&] {
for (int y = 0; y < mSize.y; ++y) {
for (int x = 0; x < mSize.x; ++x) {
glm::ivec2 i { x, y };
get(mNextPopulation, i) = [&] {
auto around = cellsAround(i);
Public Types#
Worker#
class AThreadPool::Worker
Empty structure.
Priority#
enum AThreadPool::Priority
Constant | Description |
---|---|
Priority::PRIORITY_HIGHEST
|
|
Priority::PRIORITY_MEDIUM
|
|
Priority::PRIORITY_LOWEST
|
TryLaterException#
class AThreadPool::TryLaterException
Empty structure.
Public Methods#
AThreadPool#
Initializes the thread pool with size of threads.
- Arguments
size
thread count to initialize.
Examples#
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
connect(isRunning.changed, AUI_SLOT(mTimer)::setRunning);
}
void frame() {
mFrame = AThreadPool::global() * [&] {
for (int y = 0; y < mSize.y; ++y) {
for (int x = 0; x < mSize.x; ++x) {
glm::ivec2 i { x, y };
get(mNextPopulation, i) = [&] {
auto around = cellsAround(i);
Initializes the thread pool with max(std:
of threads
or --aui-threadpool-size=SIZE passed to your application.:hardware_concurrency() - 1, 2)
Examples#
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
connect(isRunning.changed, AUI_SLOT(mTimer)::setRunning);
}
void frame() {
mFrame = AThreadPool::global() * [&] {
for (int y = 0; y < mSize.y; ++y) {
for (int x = 0; x < mSize.x; ++x) {
glm::ivec2 i { x, y };
get(mNextPopulation, i) = [&] {
auto around = cellsAround(i);
global#
Global thread pool created with the default constructor.
Examples#
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
connect(isRunning.changed, AUI_SLOT(mTimer)::setRunning);
}
void frame() {
mFrame = AThreadPool::global() * [&] {
for (int y = 0; y < mSize.y; ++y) {
for (int x = 0; x < mSize.x; ++x) {
glm::ivec2 i { x, y };
get(mNextPopulation, i) = [&] {
auto around = cellsAround(i);
examples/app/minesweeper/src/Style.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
struct GlobalStyle {
GlobalStyle() {
AStylesheet::global().addRules({
{
t<CellView>(),
FixedSize { 26_dp },
BackgroundSolid { 0xdedede_rgb },
Border { 1_px, 0xeaeaea_rgb },
parallel#
template<typename Iterator, typename Functor >
auto AThreadPool::parallel(Iterator begin, Iterator end, Functor&& functor)
- Arguments
begin
range beginend
range endfunctor
a functor of the following signature: ```cpp Result(Iterator begin, Iterator end) ```- Returns
- future set per thread (i.e. for 8 items on a 4-core processor there will be 4 futures)
- Performance note
- When this function is used to write to the source data it would not be L1-cache friendly. Consider writing results to another location.
Parallels work of some range, grouping tasks per thread (i.e. for 8 items on a 4-core processor each core will process 2 items)