channel.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // experimental/channel.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  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)
  9. //
  10. #ifndef BOOST_ASIO_EXPERIMENTAL_CHANNEL_HPP
  11. #define BOOST_ASIO_EXPERIMENTAL_CHANNEL_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/any_io_executor.hpp>
  17. #include <boost/asio/detail/type_traits.hpp>
  18. #include <boost/asio/execution/executor.hpp>
  19. #include <boost/asio/is_executor.hpp>
  20. #include <boost/asio/experimental/basic_channel.hpp>
  21. #include <boost/asio/experimental/channel_traits.hpp>
  22. #include <boost/asio/detail/push_options.hpp>
  23. namespace boost {
  24. namespace asio {
  25. namespace experimental {
  26. namespace detail {
  27. template <typename ExecutorOrSignature, typename = void>
  28. struct channel_type
  29. {
  30. template <typename... Signatures>
  31. struct inner
  32. {
  33. typedef basic_channel<any_io_executor, channel_traits<>,
  34. ExecutorOrSignature, Signatures...> type;
  35. };
  36. };
  37. template <typename ExecutorOrSignature>
  38. struct channel_type<ExecutorOrSignature,
  39. enable_if_t<
  40. is_executor<ExecutorOrSignature>::value
  41. || execution::is_executor<ExecutorOrSignature>::value
  42. >>
  43. {
  44. template <typename... Signatures>
  45. struct inner
  46. {
  47. typedef basic_channel<ExecutorOrSignature,
  48. channel_traits<>, Signatures...> type;
  49. };
  50. };
  51. } // namespace detail
  52. /// Template type alias for common use of channel.
  53. template <typename ExecutorOrSignature, typename... Signatures>
  54. using channel = typename detail::channel_type<
  55. ExecutorOrSignature>::template inner<Signatures...>::type;
  56. } // namespace experimental
  57. } // namespace asio
  58. } // namespace boost
  59. #include <boost/asio/detail/pop_options.hpp>
  60. #endif // BOOST_ASIO_EXPERIMENTAL_CHANNEL_HPP