123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- #ifndef BOOST_ASIO_SPAWN_HPP
- #define BOOST_ASIO_SPAWN_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <boost/coroutine/all.hpp>
- #include <boost/asio/any_io_executor.hpp>
- #include <boost/asio/bind_executor.hpp>
- #include <boost/asio/detail/memory.hpp>
- #include <boost/asio/detail/type_traits.hpp>
- #include <boost/asio/detail/wrapped_handler.hpp>
- #include <boost/asio/io_context.hpp>
- #include <boost/asio/is_executor.hpp>
- #include <boost/asio/strand.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- template <typename Handler>
- class basic_yield_context
- {
- public:
-
-
- #if defined(GENERATING_DOCUMENTATION)
- typedef implementation_defined callee_type;
- #elif defined(BOOST_COROUTINES_UNIDIRECT) || defined(BOOST_COROUTINES_V2)
- typedef boost::coroutines::push_coroutine<void> callee_type;
- #else
- typedef boost::coroutines::coroutine<void()> callee_type;
- #endif
-
-
-
- #if defined(GENERATING_DOCUMENTATION)
- typedef implementation_defined caller_type;
- #elif defined(BOOST_COROUTINES_UNIDIRECT) || defined(BOOST_COROUTINES_V2)
- typedef boost::coroutines::pull_coroutine<void> caller_type;
- #else
- typedef boost::coroutines::coroutine<void()>::caller_type caller_type;
- #endif
-
-
- basic_yield_context(
- const detail::weak_ptr<callee_type>& coro,
- caller_type& ca, Handler& handler)
- : coro_(coro),
- ca_(ca),
- handler_(handler),
- ec_(0)
- {
- }
-
-
- template <typename OtherHandler>
- basic_yield_context(const basic_yield_context<OtherHandler>& other)
- : coro_(other.coro_),
- ca_(other.ca_),
- handler_(other.handler_),
- ec_(other.ec_)
- {
- }
-
-
- basic_yield_context operator[](boost::system::error_code& ec) const
- {
- basic_yield_context tmp(*this);
- tmp.ec_ = &ec;
- return tmp;
- }
- #if defined(GENERATING_DOCUMENTATION)
- private:
- #endif
- detail::weak_ptr<callee_type> coro_;
- caller_type& ca_;
- Handler handler_;
- boost::system::error_code* ec_;
- };
- #if defined(GENERATING_DOCUMENTATION)
- typedef basic_yield_context<unspecified> yield_context;
- #else
- typedef basic_yield_context<
- executor_binder<void(*)(), any_io_executor> > yield_context;
- #endif
- template <typename Function>
- void spawn(BOOST_ASIO_MOVE_ARG(Function) function,
- const boost::coroutines::attributes& attributes
- = boost::coroutines::attributes());
- template <typename Handler, typename Function>
- void spawn(BOOST_ASIO_MOVE_ARG(Handler) handler,
- BOOST_ASIO_MOVE_ARG(Function) function,
- const boost::coroutines::attributes& attributes
- = boost::coroutines::attributes(),
- typename constraint<
- !is_executor<typename decay<Handler>::type>::value &&
- !execution::is_executor<typename decay<Handler>::type>::value &&
- !is_convertible<Handler&, execution_context&>::value>::type = 0);
- template <typename Handler, typename Function>
- void spawn(basic_yield_context<Handler> ctx,
- BOOST_ASIO_MOVE_ARG(Function) function,
- const boost::coroutines::attributes& attributes
- = boost::coroutines::attributes());
- template <typename Function, typename Executor>
- void spawn(const Executor& ex,
- BOOST_ASIO_MOVE_ARG(Function) function,
- const boost::coroutines::attributes& attributes
- = boost::coroutines::attributes(),
- typename constraint<
- is_executor<Executor>::value || execution::is_executor<Executor>::value
- >::type = 0);
- template <typename Function, typename Executor>
- void spawn(const strand<Executor>& ex,
- BOOST_ASIO_MOVE_ARG(Function) function,
- const boost::coroutines::attributes& attributes
- = boost::coroutines::attributes());
- #if !defined(BOOST_ASIO_NO_TS_EXECUTORS)
- template <typename Function>
- void spawn(const boost::asio::io_context::strand& s,
- BOOST_ASIO_MOVE_ARG(Function) function,
- const boost::coroutines::attributes& attributes
- = boost::coroutines::attributes());
- #endif
- template <typename Function, typename ExecutionContext>
- void spawn(ExecutionContext& ctx,
- BOOST_ASIO_MOVE_ARG(Function) function,
- const boost::coroutines::attributes& attributes
- = boost::coroutines::attributes(),
- typename constraint<is_convertible<
- ExecutionContext&, execution_context&>::value>::type = 0);
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #include <boost/asio/impl/spawn.hpp>
- #endif
|