Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

basic_yield_context

Context object the represents the currently executing coroutine.

template<
    typename Handler>
class basic_yield_context
Types

Name

Description

callee_type

The coroutine callee type, used by the implementation.

caller_type

The coroutine caller type, used by the implementation.

Member Functions

Name

Description

basic_yield_context

Construct a yield context to represent the specified coroutine.

operator[]

Return a yield context that sets the specified error_code.

The basic_yield_context class is used to represent the currently executing stackful coroutine. A basic_yield_context may be passed as a handler to an asynchronous operation. For example:

template <typename Handler>
void my_coroutine(basic_yield_context<Handler> yield)
{
  ...
  std::size_t n = my_socket.async_read_some(buffer, yield);
  ...
}

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/spawn.hpp

Convenience header: boost/asio.hpp


PrevUpHomeNext