]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/signal_set_service.hpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / boost / asio / signal_set_service.hpp
1 //
2 // signal_set_service.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2018 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_SIGNAL_SET_SERVICE_HPP
12 #define BOOST_ASIO_SIGNAL_SET_SERVICE_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
20 #if defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
21
22 #include <boost/asio/async_result.hpp>
23 #include <boost/asio/detail/signal_set_service.hpp>
24 #include <boost/asio/error.hpp>
25 #include <boost/asio/io_context.hpp>
26
27 #include <boost/asio/detail/push_options.hpp>
28
29 namespace boost {
30 namespace asio {
31
32 /// Default service implementation for a signal set.
33 class signal_set_service
34 #if defined(GENERATING_DOCUMENTATION)
35 : public boost::asio::io_context::service
36 #else
37 : public boost::asio::detail::service_base<signal_set_service>
38 #endif
39 {
40 public:
41 #if defined(GENERATING_DOCUMENTATION)
42 /// The unique service identifier.
43 static boost::asio::io_context::id id;
44 #endif
45
46 public:
47 /// The type of a signal set implementation.
48 #if defined(GENERATING_DOCUMENTATION)
49 typedef implementation_defined implementation_type;
50 #else
51 typedef detail::signal_set_service::implementation_type implementation_type;
52 #endif
53
54 /// Construct a new signal set service for the specified io_context.
55 explicit signal_set_service(boost::asio::io_context& io_context)
56 : boost::asio::detail::service_base<signal_set_service>(io_context),
57 service_impl_(io_context)
58 {
59 }
60
61 /// Construct a new signal set implementation.
62 void construct(implementation_type& impl)
63 {
64 service_impl_.construct(impl);
65 }
66
67 /// Destroy a signal set implementation.
68 void destroy(implementation_type& impl)
69 {
70 service_impl_.destroy(impl);
71 }
72
73 /// Add a signal to a signal_set.
74 BOOST_ASIO_SYNC_OP_VOID add(implementation_type& impl,
75 int signal_number, boost::system::error_code& ec)
76 {
77 service_impl_.add(impl, signal_number, ec);
78 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
79 }
80
81 /// Remove a signal to a signal_set.
82 BOOST_ASIO_SYNC_OP_VOID remove(implementation_type& impl,
83 int signal_number, boost::system::error_code& ec)
84 {
85 service_impl_.remove(impl, signal_number, ec);
86 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
87 }
88
89 /// Remove all signals from a signal_set.
90 BOOST_ASIO_SYNC_OP_VOID clear(implementation_type& impl,
91 boost::system::error_code& ec)
92 {
93 service_impl_.clear(impl, ec);
94 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
95 }
96
97 /// Cancel all operations associated with the signal set.
98 BOOST_ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
99 boost::system::error_code& ec)
100 {
101 service_impl_.cancel(impl, ec);
102 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
103 }
104
105 // Start an asynchronous operation to wait for a signal to be delivered.
106 template <typename SignalHandler>
107 BOOST_ASIO_INITFN_RESULT_TYPE(SignalHandler,
108 void (boost::system::error_code, int))
109 async_wait(implementation_type& impl,
110 BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
111 {
112 async_completion<SignalHandler,
113 void (boost::system::error_code, int)> init(handler);
114
115 service_impl_.async_wait(impl, init.completion_handler);
116
117 return init.result.get();
118 }
119
120 private:
121 // Destroy all user-defined handler objects owned by the service.
122 void shutdown()
123 {
124 service_impl_.shutdown();
125 }
126
127 // Perform any fork-related housekeeping.
128 void notify_fork(boost::asio::io_context::fork_event event)
129 {
130 service_impl_.notify_fork(event);
131 }
132
133 // The platform-specific implementation.
134 detail::signal_set_service service_impl_;
135 };
136
137 } // namespace asio
138 } // namespace boost
139
140 #include <boost/asio/detail/pop_options.hpp>
141
142 #endif // defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
143
144 #endif // BOOST_ASIO_SIGNAL_SET_SERVICE_HPP