11 #ifndef ASIO_EXECUTION_DETAIL_AS_INVOCABLE_HPP 12 #define ASIO_EXECUTION_DETAIL_AS_INVOCABLE_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 19 #include "asio/detail/atomic_count.hpp" 20 #include "asio/detail/memory.hpp" 21 #include "asio/detail/type_traits.hpp" 22 #include "asio/execution/receiver_invocation_error.hpp" 23 #include "asio/execution/set_done.hpp" 24 #include "asio/execution/set_error.hpp" 25 #include "asio/execution/set_value.hpp" 27 #include "asio/detail/push_options.hpp" 33 #if defined(ASIO_HAS_MOVE) 35 template <
typename Receiver,
typename>
40 explicit as_invocable(Receiver& r) ASIO_NOEXCEPT
41 : receiver_(asio::detail::addressof(r))
45 as_invocable(as_invocable&& other) ASIO_NOEXCEPT
46 : receiver_(other.receiver_)
54 execution::set_done(ASIO_MOVE_OR_LVALUE(Receiver)(*receiver_));
57 void operator()() ASIO_LVALUE_REF_QUAL ASIO_NOEXCEPT
59 #if !defined(ASIO_NO_EXCEPTIONS) 62 #endif // !defined(ASIO_NO_EXCEPTIONS) 63 execution::set_value(ASIO_MOVE_CAST(Receiver)(*receiver_));
65 #if !defined(ASIO_NO_EXCEPTIONS) 69 #if defined(ASIO_HAS_STD_EXCEPTION_PTR) 70 execution::set_error(ASIO_MOVE_CAST(Receiver)(*receiver_),
71 std::make_exception_ptr(receiver_invocation_error()));
73 #else // defined(ASIO_HAS_STD_EXCEPTION_PTR) 75 #endif // defined(ASIO_HAS_STD_EXCEPTION_PTR) 77 #endif // !defined(ASIO_NO_EXCEPTIONS) 81 #else // defined(ASIO_HAS_MOVE) 83 template <
typename Receiver,
typename>
87 asio::detail::shared_ptr<asio::detail::atomic_count> ref_count_;
90 const asio::detail::shared_ptr<
91 asio::detail::atomic_count>& c) ASIO_NOEXCEPT
92 : receiver_(asio::detail::addressof(r)),
98 : receiver_(other.receiver_),
99 ref_count_(other.ref_count_)
106 if (--(*ref_count_) == 0)
107 execution::set_done(*receiver_);
110 void operator()() ASIO_LVALUE_REF_QUAL ASIO_NOEXCEPT
112 #if !defined(ASIO_NO_EXCEPTIONS) 115 #endif // !defined(ASIO_NO_EXCEPTIONS) 116 execution::set_value(*receiver_);
119 #if !defined(ASIO_NO_EXCEPTIONS) 122 #if defined(ASIO_HAS_STD_EXCEPTION_PTR) 123 execution::set_error(*receiver_,
126 #else // defined(ASIO_HAS_STD_EXCEPTION_PTR) 128 #endif // defined(ASIO_HAS_STD_EXCEPTION_PTR) 130 #endif // !defined(ASIO_NO_EXCEPTIONS) 134 #endif // defined(ASIO_HAS_MOVE) 136 template <
typename T>
141 template <
typename Function,
typename T>
150 #include "asio/detail/pop_options.hpp" 152 #endif // ASIO_EXECUTION_DETAIL_AS_INVOCABLE_HPP Definition: as_invocable.hpp:84
Definition: as_invocable.hpp:137
Definition: handler_work.hpp:37
Exception reported via set_error when an exception escapes from set_value.
Definition: receiver_invocation_error.hpp:28
Definition: any_io_executor.hpp:28