]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // |
2 | // system_context.hpp | |
3 | // ~~~~~~~~~~~~~~~~~~ | |
4 | // | |
f67539c2 | 5 | // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
b32b8144 FG |
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_context.hpp> | |
22 | ||
23 | #include <boost/asio/detail/push_options.hpp> | |
24 | ||
25 | namespace boost { | |
26 | namespace asio { | |
27 | ||
28 | class system_executor; | |
29 | ||
30 | /// The executor context for the system executor. | |
31 | class system_context : public execution_context | |
32 | { | |
33 | public: | |
34 | /// The executor type associated with the context. | |
35 | typedef system_executor executor_type; | |
36 | ||
37 | /// Destructor shuts down all threads in the system thread pool. | |
38 | BOOST_ASIO_DECL ~system_context(); | |
39 | ||
40 | /// Obtain an executor for the context. | |
41 | executor_type get_executor() BOOST_ASIO_NOEXCEPT; | |
42 | ||
43 | /// Signal all threads in the system thread pool to stop. | |
44 | BOOST_ASIO_DECL void stop(); | |
45 | ||
46 | /// Determine whether the system thread pool has been stopped. | |
47 | BOOST_ASIO_DECL bool stopped() const BOOST_ASIO_NOEXCEPT; | |
48 | ||
49 | /// Join all threads in the system thread pool. | |
50 | BOOST_ASIO_DECL void join(); | |
51 | ||
52 | #if defined(GENERATING_DOCUMENTATION) | |
53 | private: | |
54 | #endif // defined(GENERATING_DOCUMENTATION) | |
55 | // Constructor creates all threads in the system thread pool. | |
56 | BOOST_ASIO_DECL system_context(); | |
57 | ||
58 | private: | |
59 | friend class system_executor; | |
60 | ||
61 | struct thread_function; | |
62 | ||
92f5a8d4 TL |
63 | // Helper function to create the underlying scheduler. |
64 | BOOST_ASIO_DECL detail::scheduler& add_scheduler(detail::scheduler* s); | |
65 | ||
b32b8144 FG |
66 | // The underlying scheduler. |
67 | detail::scheduler& scheduler_; | |
68 | ||
69 | // The threads in the system thread pool. | |
70 | detail::thread_group threads_; | |
71 | }; | |
72 | ||
73 | } // namespace asio | |
74 | } // namespace boost | |
75 | ||
76 | #include <boost/asio/detail/pop_options.hpp> | |
77 | ||
78 | #include <boost/asio/impl/system_context.hpp> | |
79 | #if defined(BOOST_ASIO_HEADER_ONLY) | |
80 | # include <boost/asio/impl/system_context.ipp> | |
81 | #endif // defined(BOOST_ASIO_HEADER_ONLY) | |
82 | ||
83 | #endif // BOOST_ASIO_SYSTEM_CONTEXT_HPP |