Expand description
Low-level async integration with Windows APCs
Some Win32 APIs deliver their completion as a user-mode APC to whichever thread made the call,
and require that thread to periodically enter an alertable wait
(SleepEx/WaitForSingleObjectEx with bAlertable = TRUE). This module is deliberately
agnostic to any particular such API: it only provides the alertable thread, task creation, and
cooperative cancellation.
§Cancellation
Dropping the Task returned by Reactor::submit cancels the task. By default this simply
drops the corresponding future in the reactor thread. A task that needs to do something before
being torn down can call Context::cancel_guard, which turns a cancellation request arriving
during that region into a cooperative Err instead of a drop, so the task’s own code can run
async cleanup before finishing normally.
Structs§
- Canceled
- Error returned when cancellation reaches
Context::cancel_guard. - Closed
- Error returned by
Reactor::submitwhen the reactor is closed. - Context
- Context handle provided to APC tasks.
- Control
- Allows closing and awaiting exit of a
Reactor. - Join
- Future returned by
Control::join. - Reactor
- A handle for submitting work to a reactor.
- Task
- A future result of a task.
- Task
Canceled - Error returned when a reactor task is cancelled before producing a value.