concurrent_channel.hpp 2.0 KB

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