scheduler.hpp 2.3 KB

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