File indexing completed on 2025-01-18 09:28:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_HANDLER_HPP
0012 #define BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_HANDLER_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/associator.hpp>
0020 #include <boost/asio/experimental/detail/channel_payload.hpp>
0021
0022 #include <boost/asio/detail/push_options.hpp>
0023
0024 namespace boost {
0025 namespace asio {
0026 namespace experimental {
0027 namespace detail {
0028
0029 template <typename Payload, typename Handler>
0030 class channel_handler
0031 {
0032 public:
0033 channel_handler(Payload&& p, Handler& h)
0034 : payload_(static_cast<Payload&&>(p)),
0035 handler_(static_cast<Handler&&>(h))
0036 {
0037 }
0038
0039 void operator()()
0040 {
0041 payload_.receive(handler_);
0042 }
0043
0044
0045 Payload payload_;
0046 Handler handler_;
0047 };
0048
0049 }
0050 }
0051
0052 template <template <typename, typename> class Associator,
0053 typename Payload, typename Handler, typename DefaultCandidate>
0054 struct associator<Associator,
0055 experimental::detail::channel_handler<Payload, Handler>,
0056 DefaultCandidate>
0057 : Associator<Handler, DefaultCandidate>
0058 {
0059 static typename Associator<Handler, DefaultCandidate>::type get(
0060 const experimental::detail::channel_handler<Payload, Handler>& h) noexcept
0061 {
0062 return Associator<Handler, DefaultCandidate>::get(h.handler_);
0063 }
0064
0065 static auto get(
0066 const experimental::detail::channel_handler<Payload, Handler>& h,
0067 const DefaultCandidate& c) noexcept
0068 -> decltype(Associator<Handler, DefaultCandidate>::get(h.handler_, c))
0069 {
0070 return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
0071 }
0072 };
0073
0074 }
0075 }
0076
0077 #include <boost/asio/detail/pop_options.hpp>
0078
0079 #endif