Context object the represents the currently executing coroutine. More...
#include <spawn.hpp>
Public Types | |
typedef boost::coroutines::coroutine < void()> | callee_type |
The coroutine callee type, used by the implementation. More... | |
typedef boost::coroutines::coroutine < void()>::caller_type | caller_type |
The coroutine caller type, used by the implementation. More... | |
Public Member Functions | |
basic_yield_context (const detail::weak_ptr< callee_type > &coro, caller_type &ca, Handler &handler) | |
Construct a yield context to represent the specified coroutine. More... | |
basic_yield_context | operator[] (boost::system::error_code &ec) const |
Return a yield context that sets the specified error_code. More... | |
Public Attributes | |
detail::weak_ptr< callee_type > | coro_ |
caller_type & | ca_ |
Handler & | handler_ |
boost::system::error_code * | ec_ |
Context object the represents the currently executing coroutine.
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:
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.
typedef boost::coroutines::coroutine<void()> boost::asio::basic_yield_context< Handler >::callee_type |
The coroutine callee type, used by the implementation.
When using Boost.Coroutine v1, this type is:
When using Boost.Coroutine v2 (unidirectional coroutines), this type is:
typedef boost::coroutines::coroutine<void()>::caller_type boost::asio::basic_yield_context< Handler >::caller_type |
The coroutine caller type, used by the implementation.
When using Boost.Coroutine v1, this type is:
When using Boost.Coroutine v2 (unidirectional coroutines), this type is:
|
inline |
Construct a yield context to represent the specified coroutine.
Most applications do not need to use this constructor. Instead, the spawn() function passes a yield context as an argument to the coroutine function.
|
inline |
Return a yield context that sets the specified error_code.
By default, when a yield context is used with an asynchronous operation, a non-success error_code is converted to system_error and thrown. This operator may be used to specify an error_code object that should instead be set with the asynchronous operation's result. For example:
References boost::asio::basic_yield_context< Handler >::ec_.
caller_type& boost::asio::basic_yield_context< Handler >::ca_ |
detail::weak_ptr<callee_type> boost::asio::basic_yield_context< Handler >::coro_ |
boost::system::error_code* boost::asio::basic_yield_context< Handler >::ec_ |
Referenced by boost::asio::basic_yield_context< Handler >::operator[]().
Handler& boost::asio::basic_yield_context< Handler >::handler_ |