1 //
2 // scheduler.cpp
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 
11 // Disable autolinking for unit tests.
12 #if !defined(BOOST_ALL_NO_LIB)
13 #define BOOST_ALL_NO_LIB 1
14 #endif // !defined(BOOST_ALL_NO_LIB)
15 
16 // Test that header file is self-contained.
17 #include "asio/execution/scheduler.hpp"
18 
19 #include "../unit_test.hpp"
20 
21 namespace exec = asio::execution;
22 
23 struct not_a_scheduler
24 {
25 };
26 
27 struct executor
28 {
executorexecutor29   executor()
30   {
31   }
32 
executorexecutor33   executor(const executor&) ASIO_NOEXCEPT
34   {
35   }
36 
37 #if defined(ASIO_HAS_MOVE)
executorexecutor38   executor(executor&&) ASIO_NOEXCEPT
39   {
40   }
41 #endif // defined(ASIO_HAS_MOVE)
42 
43   template <typename F>
executeexecutor44   void execute(ASIO_MOVE_ARG(F) f) const ASIO_NOEXCEPT
45   {
46     (void)f;
47   }
48 
operator ==executor49   bool operator==(const executor&) const ASIO_NOEXCEPT
50   {
51     return true;
52   }
53 
operator !=executor54   bool operator!=(const executor&) const ASIO_NOEXCEPT
55   {
56     return false;
57   }
58 };
59 
60 namespace asio {
61 namespace traits {
62 
63 #if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
64 
65 template <typename F>
66 struct execute_member<executor, F>
67 {
68   ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
69   ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
70   typedef void result_type;
71 };
72 
73 #endif // !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
74 #if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
75 
76 template <>
77 struct equality_comparable<executor>
78 {
79   ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
80   ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
81 };
82 
83 #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
84 
85 } // namespace traits
86 } // namespace asio
87 
test_is_scheduler()88 void test_is_scheduler()
89 {
90   ASIO_CHECK(!exec::is_scheduler<void>::value);
91   ASIO_CHECK(!exec::is_scheduler<not_a_scheduler>::value);
92   ASIO_CHECK(exec::is_scheduler<executor>::value);
93 }
94 
95 ASIO_TEST_SUITE
96 (
97   "scheduler",
98   ASIO_TEST_CASE(test_is_scheduler)
99 )
100