4 ms·
The underlying implementation sets the task as cancelled the first time it is polled, and then waits for it to stop running [0]. So you could just call `cancel`
by ibraheemdev 5y ago
The underlying implementation sets the task as cancelled the first time it is polled, and then waits for it to stop running [0]. So you could just call `cancel` and poll the future once:
futures::poll!(task.cancel());
[0]: https://docs.rs/async-task/4.0.3/src/async_task/task.rs.html#124 https://docs.rs/async-task/4.0.3/src/async_task/task.rs.html...
- sizediterable 5y agoThis seems to be for the `async-task` crate. My question was about `async_std::task` in particular since it doesn't have cancel-on-drop behavior.
- ibraheemdev 5y agoasync-std uses async-task under the hood. (async-std -> async-global-executor -> async-executor -> async-task)
- sizediterable 5y agoah, makes sense!