Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:50

0001 //
0002 // experimental/detail/channel_handler.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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 // defined(_MSC_VER) && (_MSC_VER >= 1200)
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 //private:
0045   Payload payload_;
0046   Handler handler_;
0047 };
0048 
0049 } // namespace detail
0050 } // namespace experimental
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 } // namespace asio
0075 } // namespace boost
0076 
0077 #include <boost/asio/detail/pop_options.hpp>
0078 
0079 #endif // BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_HANDLER_HPP