boost::capy::this_coro

Namespace for coroutine environment accessors.

Description

The this_coro namespace contains tag objects that can be awaited to retrieve information about the current coroutine's execution context. These tags are intercepted by a promise type's await_transform to yield the appropriate values without suspending.

Example

task<void> example()
{
    auto const& env = co_await this_coro::environment;
    auto ex = co_await this_coro::executor;
    auto token = co_await this_coro::stop_token;
    auto* alloc = co_await this_coro::allocator;
}

Types

Name

Description

allocator_tag

Tag type for coroutine allocator retrieval.

environment_tag

Tag type for coroutine environment retrieval.

executor_tag

Tag type for coroutine executor retrieval.

stop_token_tag

Tag type for coroutine stop token retrieval.

Variables

Name

Description

allocator

Tag object that yields the current frame allocator when awaited.

environment

Tag object that yields the current environment when awaited.

executor

Tag object that yields the current executor when awaited.

stop_token

Tag object that yields the current stop token when awaited.

See Also

io_awaitable_promise_base, io_env

Created with MrDocs