]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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:CompletionHandler Completion handler requirements] | |
9 | ||
10 | A completion handler must meet the requirements for a [link | |
11 | boost_asio.reference.Handler handler]. A value `h` of a completion handler | |
12 | class should work correctly in the expression `h()`. | |
13 | ||
14 | [heading Examples] | |
15 | ||
16 | A free function as a completion handler: | |
17 | ||
18 | void completion_handler() | |
19 | { | |
20 | ... | |
21 | } | |
22 | ||
23 | A completion handler function object: | |
24 | ||
25 | struct completion_handler | |
26 | { | |
27 | ... | |
28 | void operator()() | |
29 | { | |
30 | ... | |
31 | } | |
32 | ... | |
33 | }; | |
34 | ||
35 | A non-static class member function adapted to a completion handler using | |
36 | `bind()`: | |
37 | ||
38 | void my_class::completion_handler() | |
39 | { | |
40 | ... | |
41 | } | |
42 | ... | |
43 | my_io_service.post(boost::bind(&my_class::completion_handler, this)); | |
44 | ||
45 | [endsect] |