Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

experimental::await_token

A completion token that represents the currently executing coroutine.

template<
    typename Executor>
class await_token
Types

Name

Description

executor_type

The associated executor type.

Member Functions

Name

Description

await_token

Copy constructor.

Move constructor.

get_executor

Get the associated executor.

The experimental::await_token class is used to represent the currently executing coroutine. An experimental::await_token may be passed as a handler to an asynchronous operation. For example:

awaitable<void> my_coroutine()
{
  await_token token = co_await this_coro::token();
  ...
  std::size_t n = co_await my_socket.async_read_some(buffer, token);
  ...
}

The initiating function (async_read_some in the above example) suspends the current coroutine. The coroutine is resumed when the asynchronous operation completes, and the result of the operation is returned.

Requirements

Header: boost/asio/experimental/co_spawn.hpp

Convenience header: boost/asio/experimental.hpp


PrevUpHomeNext