]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/signal_set_service.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / asio / signal_set_service.hpp
CommitLineData
7c673cae
FG
1//
2// signal_set_service.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~
4//
11fdf7f2 5// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7c673cae
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_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>
b32b8144
FG
19
20#if defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
21
7c673cae
FG
22#include <boost/asio/async_result.hpp>
23#include <boost/asio/detail/signal_set_service.hpp>
24#include <boost/asio/error.hpp>
b32b8144 25#include <boost/asio/io_context.hpp>
7c673cae
FG
26
27#include <boost/asio/detail/push_options.hpp>
28
29namespace boost {
30namespace asio {
31
32/// Default service implementation for a signal set.
33class signal_set_service
34#if defined(GENERATING_DOCUMENTATION)
b32b8144 35 : public boost::asio::io_context::service
7c673cae
FG
36#else
37 : public boost::asio::detail::service_base<signal_set_service>
38#endif
39{
40public:
41#if defined(GENERATING_DOCUMENTATION)
42 /// The unique service identifier.
b32b8144 43 static boost::asio::io_context::id id;
7c673cae
FG
44#endif
45
46public:
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
b32b8144
FG
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)
7c673cae
FG
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.
b32b8144 74 BOOST_ASIO_SYNC_OP_VOID add(implementation_type& impl,
7c673cae
FG
75 int signal_number, boost::system::error_code& ec)
76 {
b32b8144
FG
77 service_impl_.add(impl, signal_number, ec);
78 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
7c673cae
FG
79 }
80
81 /// Remove a signal to a signal_set.
b32b8144 82 BOOST_ASIO_SYNC_OP_VOID remove(implementation_type& impl,
7c673cae
FG
83 int signal_number, boost::system::error_code& ec)
84 {
b32b8144
FG
85 service_impl_.remove(impl, signal_number, ec);
86 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
7c673cae
FG
87 }
88
89 /// Remove all signals from a signal_set.
b32b8144 90 BOOST_ASIO_SYNC_OP_VOID clear(implementation_type& impl,
7c673cae
FG
91 boost::system::error_code& ec)
92 {
b32b8144
FG
93 service_impl_.clear(impl, ec);
94 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
7c673cae
FG
95 }
96
97 /// Cancel all operations associated with the signal set.
b32b8144 98 BOOST_ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
7c673cae
FG
99 boost::system::error_code& ec)
100 {
b32b8144
FG
101 service_impl_.cancel(impl, ec);
102 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
7c673cae
FG
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 {
b32b8144
FG
112 async_completion<SignalHandler,
113 void (boost::system::error_code, int)> init(handler);
7c673cae 114
b32b8144 115 service_impl_.async_wait(impl, init.completion_handler);
7c673cae
FG
116
117 return init.result.get();
118 }
119
120private:
121 // Destroy all user-defined handler objects owned by the service.
b32b8144 122 void shutdown()
7c673cae 123 {
b32b8144 124 service_impl_.shutdown();
7c673cae
FG
125 }
126
127 // Perform any fork-related housekeeping.
b32b8144 128 void notify_fork(boost::asio::io_context::fork_event event)
7c673cae 129 {
b32b8144 130 service_impl_.notify_fork(event);
7c673cae
FG
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
b32b8144
FG
142#endif // defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
143
7c673cae 144#endif // BOOST_ASIO_SIGNAL_SET_SERVICE_HPP