boost::capy::this_coro::stop_token
Tag object that yields the current stop token when awaited.
Synopsis
Declared in <boost/capy/ex/this_coro.hpp>
inline constexpr stop_token_tag stop_token = {};
Description
Use co_await this_coro::stop_token inside a coroutine whose promise type supports stop token access (e.g., inherits from io_awaitable_promise_base). The returned stop token reflects whatever token was passed to this coroutine when it was awaited.
Example
task<void> cancellable_work()
{
auto token = co_await this_coro::stop_token;
if (token.stop_requested())
co_return;
}
Behavior
-
If no stop token was propagated, returns a default‐constructed `std::stop_token` (where `stop_possible()` returns `false`).
-
The returned token remains valid for the coroutine's lifetime.
-
This operation never suspends; `await_ready()` always returns `true`.