6#ifndef BOOST_FIBERS_ASIO_DETAIL_YIELD_HPP
7#define BOOST_FIBERS_ASIO_DETAIL_YIELD_HPP
9#include <boost/asio/async_result.hpp>
10#include <boost/asio/detail/config.hpp>
11#include <boost/asio/handler_type.hpp>
12#include <boost/system/error_code.hpp>
13#include <boost/system/system_error.hpp>
14#include <boost/throw_exception.hpp>
15#include <boost/assert.hpp>
17#include <boost/fiber/all.hpp>
21#ifdef BOOST_HAS_ABI_HEADERS
22# include BOOST_ABI_PREFIX
34 typedef std::unique_lock< mutex_t >
lock_t;
48 fibers::context::active()->suspend( lk);
75 "Must inject yield_completion* "
76 "before calling yield_handler_base::operator()()");
78 "Must inject boost::system::error_code* "
79 "before calling yield_handler_base::operator()()");
92 if ( fibers::context::active() !=
ctx_ ) {
94 fibers::context::active()->set_ready(
ctx_);
99 boost::fibers::context *
ctx_;
113template<
typename T >
124 (*this)( boost::system::error_code(), std::move(t) );
130 "Must inject value ptr "
131 "before caling yield_handler<T>::operator()()");
158 ( * this)( boost::system::error_code() );
162 using yield_handler_base::operator();
168template<
typename Fn,
typename T >
181 h.
ycomp_ = & this->ycomp_;
199 throw_exception( boost::system::system_error{ ec_ } );
205 boost::system::error_code ec_{};
208 yield_completion ycomp_{};
222template<
typename T >
239 return std::move( value_);
265template<
typename ReturnType >
266struct handler_type< fibers::asio::yield_t, ReturnType() >
273template<
typename ReturnType,
typename Arg1 >
274struct handler_type< fibers::asio::yield_t, ReturnType( Arg1) >
282template<
typename ReturnType >
283struct handler_type< fibers::asio::yield_t, ReturnType( boost::system::error_code) >
292template<
typename ReturnType,
typename Arg2 >
293struct handler_type< fibers::asio::yield_t, ReturnType( boost::system::error_code, Arg2) >
298#ifdef BOOST_HAS_ABI_HEADERS
299# include BOOST_ABI_SUFFIX
async_result(boost::fibers::asio::detail::yield_handler< T > &h)
async_result(boost::fibers::asio::detail::yield_handler< void > &h)
async_result_base(yield_handler_base &h)
yield_handler(yield_t const &y)
boost::fibers::context * ctx_
yield_handler_base(yield_t const &y)
void operator()(boost::system::error_code const &ec)
yield_completion * ycomp_
void operator()(boost::system::error_code const &ec, T t)
yield_handler(yield_t const &y)
boost::system::error_code * ec_
void asio_handler_invoke(Fn fn, yield_handler< T > *h)
#define T(meth, val, expected)
fibers::asio::detail::yield_handler< void > type
fibers::asio::detail::yield_handler< Arg1 > type
fibers::asio::detail::yield_handler< void > type
fibers::asio::detail::yield_handler< Arg2 > type
fibers::detail::spinlock mutex_t
std::unique_lock< mutex_t > lock_t