Class SuspendJob¶
Defined in File job.h
Class Documentation¶
-
class SuspendJob¶
Awaiter for suspending a Job and re-dispatching it to the scheduler.
When a Job executes
co_await SuspendJob(), the job is suspended and re-queued in the scheduler, allowing the worker thread to process other work instead of blocking. The suspended job will be resumed later when a worker picks it up.This is the core mechanism that enables the work-stealing scheduler’s efficiency: workers never idle waiting for specific jobs - they continuously process available work.
Example:
Job<void> long_operation() { do_work_phase1(); co_await SuspendJob(); // Yield to allow other work do_work_phase2(); co_return; }
Public Functions
-
inline constexpr bool await_ready() noexcept¶
-
std::coroutine_handle await_suspend(std::coroutine_handle<> handle) noexcept¶
Suspends the job and re-queues it in the scheduler.
- Parameters:
handle – The coroutine handle to suspend
- Returns:
Handle to resume next (scheduler continuation)
-
inline void await_resume() noexcept¶
-
inline constexpr bool await_ready() noexcept¶