Realistic 3D camera system
3D camera system components
Public Types | Public Member Functions | Public Attributes | List of all members
asio::basic_yield_context< Handler > Class Template Reference

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[] (asio::error_code &ec) const
 Return a yield context that sets the specified error_code. More...
 

Public Attributes

detail::weak_ptr< callee_typecoro_
 
caller_typeca_
 
Handler & handler_
 
asio::error_codeec_
 

Detailed Description

template<typename Handler>
class asio::basic_yield_context< Handler >

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:

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.

Definition at line 48 of file spawn.hpp.

Member Typedef Documentation

template<typename Handler>
typedef boost::coroutines::coroutine<void()> 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:

push_coroutine<void>

Definition at line 63 of file spawn.hpp.

template<typename Handler>
typedef boost::coroutines::coroutine<void()>::caller_type 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:

pull_coroutine<void>

Definition at line 78 of file spawn.hpp.

Constructor & Destructor Documentation

template<typename Handler>
asio::basic_yield_context< Handler >::basic_yield_context ( const detail::weak_ptr< callee_type > &  coro,
caller_type ca,
Handler &  handler 
)
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.

Definition at line 87 of file spawn.hpp.

Member Function Documentation

template<typename Handler>
basic_yield_context asio::basic_yield_context< Handler >::operator[] ( asio::error_code ec) const
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:

template <typename Handler>
void my_coroutine(basic_yield_context<Handler> yield)
{
...
std::size_t n = my_socket.async_read_some(buffer, yield[ec]);
if (ec)
{
// An error occurred.
}
...
}

Definition at line 116 of file spawn.hpp.

Member Data Documentation

template<typename Handler>
caller_type& asio::basic_yield_context< Handler >::ca_

Definition at line 127 of file spawn.hpp.

template<typename Handler>
detail::weak_ptr<callee_type> asio::basic_yield_context< Handler >::coro_

Definition at line 126 of file spawn.hpp.

template<typename Handler>
asio::error_code* asio::basic_yield_context< Handler >::ec_

Definition at line 129 of file spawn.hpp.

template<typename Handler>
Handler& asio::basic_yield_context< Handler >::handler_

Definition at line 128 of file spawn.hpp.


The documentation for this class was generated from the following file: