scheduler.hpp 2.2 KB

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