2 // execution/detail/as_operation.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_EXECUTION_DETAIL_AS_OPERATION_HPP
12 #define BOOST_ASIO_EXECUTION_DETAIL_AS_OPERATION_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/detail/memory.hpp>
20 #include <boost/asio/detail/type_traits.hpp>
21 #include <boost/asio/execution/detail/as_invocable.hpp>
22 #include <boost/asio/execution/execute.hpp>
23 #include <boost/asio/execution/set_error.hpp>
24 #include <boost/asio/traits/start_member.hpp>
26 #include <boost/asio/detail/push_options.hpp>
33 template <typename Executor, typename Receiver>
36 typename remove_cvref<Executor>::type ex_;
37 typename remove_cvref<Receiver>::type receiver_;
38 #if !defined(BOOST_ASIO_HAS_MOVE)
39 boost::asio::detail::shared_ptr<boost::asio::detail::atomic_count> ref_count_;
40 #endif // !defined(BOOST_ASIO_HAS_MOVE)
42 template <typename E, typename R>
43 explicit as_operation(BOOST_ASIO_MOVE_ARG(E) e, BOOST_ASIO_MOVE_ARG(R) r)
44 : ex_(BOOST_ASIO_MOVE_CAST(E)(e)),
45 receiver_(BOOST_ASIO_MOVE_CAST(R)(r))
46 #if !defined(BOOST_ASIO_HAS_MOVE)
47 , ref_count_(new boost::asio::detail::atomic_count(1))
48 #endif // !defined(BOOST_ASIO_HAS_MOVE)
52 void start() BOOST_ASIO_NOEXCEPT
54 #if !defined(BOOST_ASIO_NO_EXCEPTIONS)
57 #endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
59 BOOST_ASIO_MOVE_CAST(typename remove_cvref<Executor>::type)(ex_),
60 as_invocable<typename remove_cvref<Receiver>::type,
62 #if !defined(BOOST_ASIO_HAS_MOVE)
64 #endif // !defined(BOOST_ASIO_HAS_MOVE)
66 #if !defined(BOOST_ASIO_NO_EXCEPTIONS)
70 #if defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
72 BOOST_ASIO_MOVE_OR_LVALUE(
73 typename remove_cvref<Receiver>::type)(
75 std::current_exception());
76 #else // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
78 #endif // defined(BOOST_ASIO_HAS_STD_EXCEPTION_PTR)
80 #endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
85 } // namespace execution
88 #if !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
90 template <typename Executor, typename Receiver>
92 boost::asio::execution::detail::as_operation<Executor, Receiver> >
94 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
95 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
96 typedef void result_type;
99 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
101 } // namespace traits
105 #include <boost/asio/detail/pop_options.hpp>
107 #endif // BOOST_ASIO_EXECUTION_DETAIL_AS_OPERATION_HPP