maitake: task cancellation
Closed this issue · 2 comments
PR #261 adds a JoinHandle
type for maitake
's tasks. This allows awaiting the completion of a task. In most other async runtimes, JoinHandle
types also provide a way to remotely cancel/abort a task. We should implement that.
This would work by setting a status bit indicating the task is cancelled. The code for polling a task would then check this bit when transitioning to the polling state. If the bit is set, the task transitions to terminated, and drops the inner future.
It might be interesting to be able to handle this at the leaf future level as well, to simulate task cancellations on violation of something.
For example, my idea would basically be to allow the allocator to "kill" a task if it asks for something like 240TiB of memory.
@jamesmunns yeah, i think a TaskRef::cancel
API + implementing #277 (a way to get the currently-polling task as a TaskRef
) would be sufficient to allow leaf futures to cancel their parents.