• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <boost/asio/execution/scheduler.hpp>
18 
19 #include "../unit_test.hpp"
20 
21 namespace exec = boost::asio::execution;
22 
23 struct not_a_scheduler
24 {
25 };
26 
27 struct executor
28 {
executorexecutor29   executor()
30   {
31   }
32 
executorexecutor33   executor(const executor&) BOOST_ASIO_NOEXCEPT
34   {
35   }
36 
37 #if defined(BOOST_ASIO_HAS_MOVE)
executorexecutor38   executor(executor&&) BOOST_ASIO_NOEXCEPT
39   {
40   }
41 #endif // defined(BOOST_ASIO_HAS_MOVE)
42 
43   template <typename F>
executeexecutor44   void execute(BOOST_ASIO_MOVE_ARG(F) f) const BOOST_ASIO_NOEXCEPT
45   {
46     (void)f;
47   }
48 
operator ==executor49   bool operator==(const executor&) const BOOST_ASIO_NOEXCEPT
50   {
51     return true;
52   }
53 
operator !=executor54   bool operator!=(const executor&) const BOOST_ASIO_NOEXCEPT
55   {
56     return false;
57   }
58 };
59 
60 namespace boost {
61 namespace asio {
62 namespace traits {
63 
64 #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
65 
66 template <typename F>
67 struct execute_member<executor, F>
68 {
69   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
70   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
71   typedef void result_type;
72 };
73 
74 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT)
75 #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
76 
77 template <>
78 struct equality_comparable<executor>
79 {
80   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
81   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
82 };
83 
84 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
85 
86 } // namespace traits
87 } // namespace asio
88 } // namespace boost
89 
test_is_scheduler()90 void test_is_scheduler()
91 {
92   BOOST_ASIO_CHECK(!exec::is_scheduler<void>::value);
93   BOOST_ASIO_CHECK(!exec::is_scheduler<not_a_scheduler>::value);
94   BOOST_ASIO_CHECK(exec::is_scheduler<executor>::value);
95 }
96 
97 BOOST_ASIO_TEST_SUITE
98 (
99   "scheduler",
100   BOOST_ASIO_TEST_CASE(test_is_scheduler)
101 )
102