/usr/include/boost/asio/impl
NameSizeModeActions
awaitable.hpp117480644editdlrm
buffered_read_stream.hpp169250644editdlrm
buffered_write_stream.hpp164290644editdlrm
compose.hpp204610644editdlrm
connect.hpp322340644editdlrm
co_spawn.hpp88340644editdlrm
defer.hpp78030644editdlrm
detached.hpp33740644editdlrm
dispatch.hpp75670644editdlrm
error.ipp30700644editdlrm
execution_context.hpp32470644editdlrm
execution_context.ipp18010644editdlrm
executor.hpp68350644editdlrm
executor.ipp10020644editdlrm
handler_alloc_hook.ipp19840644editdlrm
io_context.hpp137280644editdlrm
io_context.ipp41080644editdlrm
multiple_exceptions.ipp12800644editdlrm
post.hpp77620644editdlrm
read.hpp451780644editdlrm
read_at.hpp283310644editdlrm
read_until.hpp1153350644editdlrm
redirect_error.hpp120150644editdlrm
serial_port_base.hpp13750644editdlrm
serial_port_base.ipp133270644editdlrm
spawn.hpp158540644editdlrm
src.hpp38330644editdlrm
system_context.hpp8750644editdlrm
system_context.ipp21090644editdlrm
system_executor.hpp63910644editdlrm
thread_pool.hpp108530644editdlrm
thread_pool.ipp31320644editdlrm
use_awaitable.hpp72440644editdlrm
use_future.hpp276100644editdlrm
write.hpp410760644editdlrm
write_at.hpp247320644editdlrm
Edit: /usr/include/boost/asio/impl/co_spawn.hpp (8834B)
// // impl/co_spawn.hpp // ~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_IMPL_CO_SPAWN_HPP #define BOOST_ASIO_IMPL_CO_SPAWN_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include #include #include #include #include #include namespace boost { namespace asio { namespace detail { template class co_spawn_work_guard { public: typedef typename decay< typename prefer_result::type >::type executor_type; co_spawn_work_guard(const Executor& ex) : executor_(boost::asio::prefer(ex, execution::outstanding_work.tracked)) { } executor_type get_executor() const BOOST_ASIO_NOEXCEPT { return executor_; } private: executor_type executor_; }; #if !defined(BOOST_ASIO_NO_TS_EXECUTORS) template struct co_spawn_work_guard::value >::type> : executor_work_guard { co_spawn_work_guard(const Executor& ex) : executor_work_guard(ex) { } }; #endif // !defined(BOOST_ASIO_NO_TS_EXECUTORS) template inline co_spawn_work_guard make_co_spawn_work_guard(const Executor& ex) { return co_spawn_work_guard(ex); } template awaitable co_spawn_entry_point( awaitable*, Executor ex, F f, Handler handler) { auto spawn_work = make_co_spawn_work_guard(ex); auto handler_work = make_co_spawn_work_guard( boost::asio::get_associated_executor(handler, ex)); (void) co_await (post)(spawn_work.get_executor(), use_awaitable_t{}); bool done = false; try { T t = co_await f(); done = true; (dispatch)(handler_work.get_executor(), [handler = std::move(handler), t = std::move(t)]() mutable { handler(std::exception_ptr(), std::move(t)); }); } catch (...) { if (done) throw; (dispatch)(handler_work.get_executor(), [handler = std::move(handler), e = std::current_exception()]() mutable { handler(e, T()); }); } } template awaitable co_spawn_entry_point( awaitable*, Executor ex, F f, Handler handler) { auto spawn_work = make_co_spawn_work_guard(ex); auto handler_work = make_co_spawn_work_guard( boost::asio::get_associated_executor(handler, ex)); (void) co_await (post)(spawn_work.get_executor(), use_awaitable_t{__FILE__, __LINE__, "co_spawn_entry_point"}); std::exception_ptr e = nullptr; try { co_await f(); } catch (...) { e = std::current_exception(); } (dispatch)(handler_work.get_executor(), [handler = std::move(handler), e]() mutable { handler(e); }); } template class awaitable_as_function { public: explicit awaitable_as_function(awaitable&& a) : awaitable_(std::move(a)) { } awaitable operator()() { return std::move(awaitable_); } private: awaitable awaitable_; }; template class initiate_co_spawn { public: typedef Executor executor_type; template explicit initiate_co_spawn(const OtherExecutor& ex) : ex_(ex) { } executor_type get_executor() const BOOST_ASIO_NOEXCEPT { return ex_; } template void operator()(Handler&& handler, F&& f) const { typedef typename result_of::type awaitable_type; auto a = (co_spawn_entry_point)(static_cast(nullptr), ex_, std::forward(f), std::forward(handler)); awaitable_handler(std::move(a), ex_).launch(); } private: Executor ex_; }; } // namespace detail template inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( CompletionToken, void(std::exception_ptr, T)) co_spawn(const Executor& ex, awaitable a, CompletionToken&& token, typename enable_if< (is_executor::value || execution::is_executor::value) && is_convertible::value >::type*) { return async_initiate( detail::initiate_co_spawn(AwaitableExecutor(ex)), token, detail::awaitable_as_function(std::move(a))); } template inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( CompletionToken, void(std::exception_ptr)) co_spawn(const Executor& ex, awaitable a, CompletionToken&& token, typename enable_if< (is_executor::value || execution::is_executor::value) && is_convertible::value >::type*) { return async_initiate( detail::initiate_co_spawn(AwaitableExecutor(ex)), token, detail::awaitable_as_function< void, AwaitableExecutor>(std::move(a))); } template inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( CompletionToken, void(std::exception_ptr, T)) co_spawn(ExecutionContext& ctx, awaitable a, CompletionToken&& token, typename enable_if< is_convertible::value && is_convertible::value >::type*) { return (co_spawn)(ctx.get_executor(), std::move(a), std::forward(token)); } template inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( CompletionToken, void(std::exception_ptr)) co_spawn(ExecutionContext& ctx, awaitable a, CompletionToken&& token, typename enable_if< is_convertible::value && is_convertible::value >::type*) { return (co_spawn)(ctx.get_executor(), std::move(a), std::forward(token)); } template ::type>::type) CompletionToken> inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, typename detail::awaitable_signature::type>::type) co_spawn(const Executor& ex, F&& f, CompletionToken&& token, typename enable_if< is_executor::value || execution::is_executor::value >::type*) { return async_initiate::type>::type>( detail::initiate_co_spawn< typename result_of::type::executor_type>(ex), token, std::forward(f)); } template ::type>::type) CompletionToken> inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, typename detail::awaitable_signature::type>::type) co_spawn(ExecutionContext& ctx, F&& f, CompletionToken&& token, typename enable_if< is_convertible::value >::type*) { return (co_spawn)(ctx.get_executor(), std::forward(f), std::forward(token)); } } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_IMPL_CO_SPAWN_HPP