]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // async_result.hpp | |
3 | // ~~~~~~~~~~~~~~~~ | |
4 | // | |
b32b8144 | 5 | // Copyright (c) 2003-2017 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 ARCHETYPES_ASYNC_RESULT_HPP | |
12 | #define ARCHETYPES_ASYNC_RESULT_HPP | |
13 | ||
14 | #include <boost/asio/async_result.hpp> | |
7c673cae FG |
15 | |
16 | namespace archetypes { | |
17 | ||
18 | struct lazy_handler | |
19 | { | |
20 | }; | |
21 | ||
22 | struct concrete_handler | |
23 | { | |
24 | concrete_handler(lazy_handler) | |
25 | { | |
26 | } | |
27 | ||
28 | template <typename Arg1> | |
29 | void operator()(Arg1) | |
30 | { | |
31 | } | |
32 | ||
33 | template <typename Arg1, typename Arg2> | |
34 | void operator()(Arg1, Arg2) | |
35 | { | |
36 | } | |
b32b8144 FG |
37 | |
38 | #if defined(BOOST_ASIO_HAS_MOVE) | |
39 | concrete_handler(concrete_handler&&) {} | |
40 | private: | |
41 | concrete_handler(const concrete_handler&); | |
42 | #endif // defined(BOOST_ASIO_HAS_MOVE) | |
7c673cae FG |
43 | }; |
44 | ||
45 | } // namespace archetypes | |
46 | ||
47 | namespace boost { | |
48 | namespace asio { | |
49 | ||
50 | template <typename Signature> | |
b32b8144 | 51 | class async_result<archetypes::lazy_handler, Signature> |
7c673cae FG |
52 | { |
53 | public: | |
b32b8144 FG |
54 | // The concrete completion handler type. |
55 | typedef archetypes::concrete_handler completion_handler_type; | |
56 | ||
7c673cae | 57 | // The return type of the initiating function. |
b32b8144 | 58 | typedef int return_type; |
7c673cae FG |
59 | |
60 | // Construct an async_result from a given handler. | |
b32b8144 | 61 | explicit async_result(completion_handler_type&) |
7c673cae FG |
62 | { |
63 | } | |
64 | ||
65 | // Obtain the value to be returned from the initiating function. | |
b32b8144 | 66 | return_type get() |
7c673cae FG |
67 | { |
68 | return 42; | |
69 | } | |
b32b8144 FG |
70 | |
71 | private: | |
72 | // Disallow copying and assignment. | |
73 | async_result(const async_result&) BOOST_ASIO_DELETED; | |
74 | async_result& operator=(const async_result&) BOOST_ASIO_DELETED; | |
7c673cae FG |
75 | }; |
76 | ||
77 | } // namespace asio | |
78 | } // namespace boost | |
79 | ||
80 | #endif // ARCHETYPES_ASYNC_RESULT_HPP |