MainThread¶
Forces task execution onto the main thread—the thread that called PowerPlant::start().
Syntax¶
Behavior¶
MainThread is a Pool with a concurrency of 1 that exclusively uses the main thread.
Only one MainThread task executes at a time.
If the main thread is occupied, subsequent tasks queue until it becomes available.
Example¶
on<Trigger<RenderCommand>, MainThread>().then([](const RenderCommand& cmd) {
// Guaranteed to run on the main thread
glDrawArrays(...);
});
Notes¶
- The main thread is defined as the thread that called
PowerPlant::start(). - Useful for APIs that require main-thread access (OpenGL, macOS AppKit, some GUI frameworks).
Warning