]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/system_context.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / system_context.hpp
1 //
2 // system_context.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
11 #ifndef BOOST_ASIO_SYSTEM_CONTEXT_HPP
12 #define BOOST_ASIO_SYSTEM_CONTEXT_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/detail/scheduler.hpp>
20 #include <boost/asio/detail/thread_group.hpp>
21 #include <boost/asio/execution.hpp>
22 #include <boost/asio/execution_context.hpp>
23
24 #include <boost/asio/detail/push_options.hpp>
25
26 namespace boost {
27 namespace asio {
28
29 template <typename Blocking, typename Relationship, typename Allocator>
30 class basic_system_executor;
31
32 /// The executor context for the system executor.
33 class system_context : public execution_context
34 {
35 public:
36 /// The executor type associated with the context.
37 typedef basic_system_executor<
38 execution::blocking_t::possibly_t,
39 execution::relationship_t::fork_t,
40 std::allocator<void>
41 > executor_type;
42
43 /// Destructor shuts down all threads in the system thread pool.
44 BOOST_ASIO_DECL ~system_context();
45
46 /// Obtain an executor for the context.
47 executor_type get_executor() BOOST_ASIO_NOEXCEPT;
48
49 /// Signal all threads in the system thread pool to stop.
50 BOOST_ASIO_DECL void stop();
51
52 /// Determine whether the system thread pool has been stopped.
53 BOOST_ASIO_DECL bool stopped() const BOOST_ASIO_NOEXCEPT;
54
55 /// Join all threads in the system thread pool.
56 BOOST_ASIO_DECL void join();
57
58 #if defined(GENERATING_DOCUMENTATION)
59 private:
60 #endif // defined(GENERATING_DOCUMENTATION)
61 // Constructor creates all threads in the system thread pool.
62 BOOST_ASIO_DECL system_context();
63
64 private:
65 template <typename, typename, typename> friend class basic_system_executor;
66
67 struct thread_function;
68
69 // Helper function to create the underlying scheduler.
70 BOOST_ASIO_DECL detail::scheduler& add_scheduler(detail::scheduler* s);
71
72 // The underlying scheduler.
73 detail::scheduler& scheduler_;
74
75 // The threads in the system thread pool.
76 detail::thread_group threads_;
77
78 // The number of threads in the pool.
79 std::size_t num_threads_;
80 };
81
82 } // namespace asio
83 } // namespace boost
84
85 #include <boost/asio/detail/pop_options.hpp>
86
87 #include <boost/asio/impl/system_context.hpp>
88 #if defined(BOOST_ASIO_HEADER_ONLY)
89 # include <boost/asio/impl/system_context.ipp>
90 #endif // defined(BOOST_ASIO_HEADER_ONLY)
91
92 #endif // BOOST_ASIO_SYSTEM_CONTEXT_HPP