Date: Sat, 4 Apr 2026 11:04:32 +0200
Hi all,
I've been reading up a bit on C++26 std::execution and I noticed that for
cancellation we still use the `std::stop_token` approach to be able to
"cancel" a coroutine by forcing the user to always call `stop_requested()`
before continuing the coroutine, in addition to needing to pass a
`std::stop_source` or `std::stop_token` around, making it pretty
inconvenient to use.
Now, there are ways to make this more automatic, for example, by embedding
the `std::stop_source` in the coroutine's promise type and checking at
every suspension / resumption point (`await_suspend()` and `await_resume()`
respectfully) whether or not the coroutine has been cancelled. If so, you
can throw an exception and let the coroutine unwind itself.
I was wondering if there is a proposal for such an automatic cancellation
feature in the works or already present?
Thanks in advance
I've been reading up a bit on C++26 std::execution and I noticed that for
cancellation we still use the `std::stop_token` approach to be able to
"cancel" a coroutine by forcing the user to always call `stop_requested()`
before continuing the coroutine, in addition to needing to pass a
`std::stop_source` or `std::stop_token` around, making it pretty
inconvenient to use.
Now, there are ways to make this more automatic, for example, by embedding
the `std::stop_source` in the coroutine's promise type and checking at
every suspension / resumption point (`await_suspend()` and `await_resume()`
respectfully) whether or not the coroutine has been cancelled. If so, you
can throw an exception and let the coroutine unwind itself.
I was wondering if there is a proposal for such an automatic cancellation
feature in the works or already present?
Thanks in advance
-- Rhidian De Wit Software Engineer - Barco
Received on 2026-04-04 09:04:47
