ThreadPool
Generated from engine/core/thread_pool.h at 862e08b. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.
#include "engine/core/thread_pool.h" · namespace labrador
class ThreadPool
Section titled “class ThreadPool”A pool of worker threads, and the one place a task's exception is caught and carried back to whoever waited for it.
NO <windows.h> HERE, WHICH IS WHAT Impl IS FOR. Spelling the private members as PTP_WORK, PTP_POOL, PTP_CLEANUP_GROUP, a TP_CALLBACK_ENVIRON and a static callback taking PVOID would open this header with it, and hand the whole Win32 surface to every module that wants a worker - engine/scene/scene.cpp and engine/app/application.h are the two - out of core/, which is the one module everything else is allowed to lean on. core/registry.h makes the same refusal for COM.
WHAT IS BEHIND THE POINTER IS THE WIN32 THREAD POOL - CreateThreadpoolWork, SubmitThreadpoolWork, a cleanup group - because it works and it is tested, and replacing it with std::thread would be rewriting a working primitive for a platform this engine does not build for yet (T1).
THE INDIRECTION IS NOT ON A HOT PATH. Scene::draw submits one task per slice of the view list per frame, and the slices are bounded by max_num_threads - a handful - so one pointer hop per submission is nothing T8 has an opinion about, where a virtual call per sprite would be.
ThreadPool · ~ThreadPool
Section titled “ThreadPool · ~ThreadPool”~ThreadPool();ThreadPool · operator=
Section titled “ThreadPool · operator=”ThreadPool& operator=(const ThreadPool&) = delete;add_task
Section titled “add_task”void add_task(std::function<void()> task);ONE THREAD SUBMITS. This is not a work-stealing queue a worker can add to: the submitted-work list is unguarded, so add_task and wait_for_tasks_to_complete belong to whichever thread owns the pool. Scene::draw is that thread, and it waits before returning. What is guarded is the other direction - a task's exception, recorded from whichever worker ran it.
wait_for_tasks_to_complete
Section titled “wait_for_tasks_to_complete”void wait_for_tasks_to_complete();Blocks until every submitted task has finished. If any task threw, the first such exception is rethrown here, on the calling thread. An exception escaping a Win32 thread-pool callback would otherwise terminate the process with no diagnostic.
min_num_threads · max_num_threads
Section titled “min_num_threads · max_num_threads”int min_num_threads() const;int max_num_threads() const;In the samples and tests
Section titled “In the samples and tests”The files that include this header directly. A file can also reach it through another header.
tests/core/thread_pool_tests.cpptests/local_multiplayer/draw_tests.cpptests/scene/fanout_tests.cpp
Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.