Clementine
null_thread.hpp
1 //
2 // detail/null_thread.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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 #ifndef ASIO_DETAIL_NULL_THREAD_HPP
12 #define ASIO_DETAIL_NULL_THREAD_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
20 #if !defined(ASIO_HAS_THREADS)
21 
22 #include "asio/detail/noncopyable.hpp"
23 #include "asio/detail/throw_error.hpp"
24 #include "asio/error.hpp"
25 
26 #include "asio/detail/push_options.hpp"
27 
28 namespace asio {
29 namespace detail {
30 
32  : private noncopyable
33 {
34 public:
35  // Constructor.
36  template <typename Function>
37  null_thread(Function, unsigned int = 0)
38  {
39  asio::detail::throw_error(
40  asio::error::operation_not_supported, "thread");
41  }
42 
43  // Destructor.
44  ~null_thread()
45  {
46  }
47 
48  // Wait for the thread to exit.
49  void join()
50  {
51  }
52 
53  // Get number of CPUs.
54  static std::size_t hardware_concurrency()
55  {
56  return 1;
57  }
58 };
59 
60 } // namespace detail
61 } // namespace asio
62 
63 #include "asio/detail/pop_options.hpp"
64 
65 #endif // !defined(ASIO_HAS_THREADS)
66 
67 #endif // ASIO_DETAIL_NULL_THREAD_HPP
Definition: noncopyable.hpp:25
Definition: chrono.h:284
Definition: null_thread.hpp:31
Definition: any_io_executor.hpp:28