scheduler.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // execution/scheduler.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 BOOST_ASIO_EXECUTION_SCHEDULER_HPP
  11. #define BOOST_ASIO_EXECUTION_SCHEDULER_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. #if !defined(BOOST_ASIO_NO_DEPRECATED)
  17. #include <boost/asio/detail/type_traits.hpp>
  18. #include <boost/asio/execution/schedule.hpp>
  19. #include <boost/asio/traits/equality_comparable.hpp>
  20. #include <boost/asio/detail/push_options.hpp>
  21. namespace boost {
  22. namespace asio {
  23. namespace execution {
  24. namespace detail {
  25. template <typename T>
  26. struct is_scheduler_base :
  27. integral_constant<bool,
  28. is_copy_constructible<typename remove_cvref<T>::type>::value
  29. && traits::equality_comparable<typename remove_cvref<T>::type>::is_valid
  30. >
  31. {
  32. };
  33. } // namespace detail
  34. /// The is_scheduler trait detects whether a type T satisfies the
  35. /// execution::scheduler concept.
  36. /**
  37. * Class template @c is_scheduler is a type trait that is derived from @c
  38. * true_type if the type @c T meets the concept definition for a scheduler for
  39. * error type @c E, otherwise @c false_type.
  40. */
  41. template <typename T>
  42. struct is_scheduler :
  43. #if defined(GENERATING_DOCUMENTATION)
  44. integral_constant<bool, automatically_determined>
  45. #else // defined(GENERATING_DOCUMENTATION)
  46. conditional<
  47. can_schedule<T>::value,
  48. detail::is_scheduler_base<T>,
  49. false_type
  50. >::type
  51. #endif // defined(GENERATING_DOCUMENTATION)
  52. {
  53. };
  54. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  55. template <typename T>
  56. BOOST_ASIO_CONSTEXPR const bool is_scheduler_v = is_scheduler<T>::value;
  57. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  58. #if defined(BOOST_ASIO_HAS_CONCEPTS)
  59. template <typename T>
  60. BOOST_ASIO_CONCEPT scheduler = is_scheduler<T>::value;
  61. #define BOOST_ASIO_EXECUTION_SCHEDULER ::boost::asio::execution::scheduler
  62. #else // defined(BOOST_ASIO_HAS_CONCEPTS)
  63. #define BOOST_ASIO_EXECUTION_SCHEDULER typename
  64. #endif // defined(BOOST_ASIO_HAS_CONCEPTS)
  65. } // namespace execution
  66. } // namespace asio
  67. } // namespace boost
  68. #include <boost/asio/detail/pop_options.hpp>
  69. #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
  70. #endif // BOOST_ASIO_EXECUTION_SCHEDULER_HPP