]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/doc/requirements/SignalHandler.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / asio / doc / requirements / SignalHandler.qbk
1 [/
2 / Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
3 /
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /]
7
8 [section:SignalHandler Signal handler requirements]
9
10 A signal handler must meet the requirements for a [link
11 boost_asio.reference.Handler handler]. A value `h` of a signal handler class
12 should work correctly in the expression `h(ec, n)`, where `ec` is an lvalue of
13 type `const error_code` and `n` is an lvalue of type `const int`.
14
15 [heading Examples]
16
17 A free function as a signal handler:
18
19 void signal_handler(
20 const boost::system::error_code& ec,
21 int signal_number)
22 {
23 ...
24 }
25
26 A signal handler function object:
27
28 struct signal_handler
29 {
30 ...
31 void operator()(
32 const boost::system::error_code& ec,
33 int signal_number)
34 {
35 ...
36 }
37 ...
38 };
39
40 A non-static class member function adapted to a signal handler using `bind()`:
41
42 void my_class::signal_handler(
43 const boost::system::error_code& ec,
44 int signal_number)
45 {
46 ...
47 }
48 ...
49 my_signal_set.async_wait(
50 boost::bind(&my_class::signal_handler,
51 this, boost::asio::placeholders::error,
52 boost::asio::placeholders::signal_number));
53
54 [endsect]