1 // Copyright 2003-2013 Christopher M. Kohlhoff 2 // Copyright Oliver Kowalke, Nat Goodspeed 2015. 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 8 #ifndef BOOST_FIBERS_ASIO_YIELD_HPP 9 #define BOOST_FIBERS_ASIO_YIELD_HPP 10 11 #include <boost/config.hpp> 12 13 #ifdef BOOST_HAS_ABI_HEADERS 14 # include BOOST_ABI_PREFIX 15 #endif 16 17 namespace boost { 18 namespace fibers { 19 namespace asio { 20 21 //[fibers_asio_yield_t 22 class yield_t { 23 public: 24 yield_t() = default; 25 26 /** 27 * @code 28 * static yield_t yield; 29 * boost::system::error_code myec; 30 * func(yield[myec]); 31 * @endcode 32 * @c yield[myec] returns an instance of @c yield_t whose @c ec_ points 33 * to @c myec. The expression @c yield[myec] "binds" @c myec to that 34 * (anonymous) @c yield_t instance, instructing @c func() to store any 35 * @c error_code it might produce into @c myec rather than throwing @c 36 * boost::system::system_error. 37 */ operator [](boost::system::error_code & ec) const38 yield_t operator[]( boost::system::error_code & ec) const { 39 yield_t tmp; 40 tmp.ec_ = & ec; 41 return tmp; 42 } 43 44 //private: 45 // ptr to bound error_code instance if any 46 boost::system::error_code * ec_{ nullptr }; 47 }; 48 //] 49 50 //[fibers_asio_yield 51 // canonical instance 52 thread_local yield_t yield{}; 53 //] 54 55 }}} 56 57 #ifdef BOOST_HAS_ABI_HEADERS 58 # include BOOST_ABI_SUFFIX 59 #endif 60 61 #include "detail/yield.hpp" 62 63 #endif // BOOST_FIBERS_ASIO_YIELD_HPP 64