boost::capy::this_coro::environment
Tag object that yields the current environment when awaited.
Synopsis
Declared in <boost/capy/ex/this_coro.hpp>
inline constexpr environment_tag environment = {};
Description
Use co_await this_coro::environment inside a coroutine whose promise type supports environment access (e.g., inherits from io_awaitable_promise_base). The returned environment contains the executor, stop token, and allocator for this coroutine.
Example
task<void> example()
{
auto const& env = co_await this_coro::environment;
// env.executor - the executor this coroutine is bound to
// env.stop_token - the stop token for cancellation
// env.allocator - the allocator for frame allocation
}
Behavior
-
Returns a const reference to the stored `io_env`
-
This operation never suspends; `await_ready()` always returns `true`
See Also
environment_tag
io_awaitable_promise_base
io_env
Created with MrDocs