Class JobPromise::JobAwaiter

Nested Relationships

This class is a nested type of Class JobPromise.

Class Documentation

class JobAwaiter

Awaiter for suspending parent job until child job completes.

When a Job is co_awaited (e.g., co_await child_job()), this awaiter:

  1. Checks if child is already complete (await_ready)

  2. Sets parent as continuation and dispatches child (await_suspend)

  3. Returns child’s result when resumed (await_resume)

Public Functions

inline explicit JobAwaiter(const std::coroutine_handle<JobPromise> handle)

Construct awaiter for a job.

Parameters:

handle – Handle to the job being awaited

bool await_ready() noexcept

Check if job is already complete (optimization to skip suspension).

Returns:

true if job already finished, false if must suspend

std::coroutine_handle<JobPromise> await_suspend(std::coroutine_handle<> caller) noexcept

Suspend calling job and establish parent-child relationship.

Parameters:

caller – The parent job’s coroutine handle

Returns:

Handle to resume next (the child job to execute)

template<typename T = void>
inline void await_resume() noexcept
template<typename T>
inline std::expected<T, JobResultStatus> await_resume() noexcept