]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/dispatch.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / asio / dispatch.hpp
1 //
2 // dispatch.hpp
3 // ~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 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_DISPATCH_HPP
12 #define BOOST_ASIO_DISPATCH_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 #include <boost/asio/async_result.hpp>
20 #include <boost/asio/detail/type_traits.hpp>
21 #include <boost/asio/execution_context.hpp>
22 #include <boost/asio/is_executor.hpp>
23
24 #include <boost/asio/detail/push_options.hpp>
25
26 namespace boost {
27 namespace asio {
28
29 /// Submits a completion token or function object for execution.
30 /**
31 * This function submits an object for execution using the object's associated
32 * executor. The function object is queued for execution, and is never called
33 * from the current thread prior to returning from <tt>dispatch()</tt>.
34 *
35 * This function has the following effects:
36 *
37 * @li Constructs a function object handler of type @c Handler, initialized
38 * with <tt>handler(forward<CompletionToken>(token))</tt>.
39 *
40 * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
41 * initializing the object as <tt>result(handler)</tt>.
42 *
43 * @li Obtains the handler's associated executor object @c ex by performing
44 * <tt>get_associated_executor(handler)</tt>.
45 *
46 * @li Obtains the handler's associated allocator object @c alloc by performing
47 * <tt>get_associated_allocator(handler)</tt>.
48 *
49 * @li Performs <tt>ex.dispatch(std::move(handler), alloc)</tt>.
50 *
51 * @li Returns <tt>result.get()</tt>.
52 */
53 template <typename CompletionToken>
54 BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
55 BOOST_ASIO_MOVE_ARG(CompletionToken) token);
56
57 /// Submits a completion token or function object for execution.
58 /**
59 * This function submits an object for execution using the specified executor.
60 * The function object is queued for execution, and is never called from the
61 * current thread prior to returning from <tt>dispatch()</tt>.
62 *
63 * This function has the following effects:
64 *
65 * @li Constructs a function object handler of type @c Handler, initialized
66 * with <tt>handler(forward<CompletionToken>(token))</tt>.
67 *
68 * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
69 * initializing the object as <tt>result(handler)</tt>.
70 *
71 * @li Obtains the handler's associated executor object @c ex1 by performing
72 * <tt>get_associated_executor(handler)</tt>.
73 *
74 * @li Creates a work object @c w by performing <tt>make_work(ex1)</tt>.
75 *
76 * @li Obtains the handler's associated allocator object @c alloc by performing
77 * <tt>get_associated_allocator(handler)</tt>.
78 *
79 * @li Constructs a function object @c f with a function call operator that
80 * performs <tt>ex1.dispatch(std::move(handler), alloc)</tt> followed by
81 * <tt>w.reset()</tt>.
82 *
83 * @li Performs <tt>Executor(ex).dispatch(std::move(f), alloc)</tt>.
84 *
85 * @li Returns <tt>result.get()</tt>.
86 */
87 template <typename Executor, typename CompletionToken>
88 BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
89 const Executor& ex, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
90 typename enable_if<is_executor<Executor>::value>::type* = 0);
91
92 /// Submits a completion token or function object for execution.
93 /**
94 * @returns <tt>dispatch(ctx.get_executor(),
95 * forward<CompletionToken>(token))</tt>.
96 */
97 template <typename ExecutionContext, typename CompletionToken>
98 BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
99 ExecutionContext& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
100 typename enable_if<is_convertible<
101 ExecutionContext&, execution_context&>::value>::type* = 0);
102
103 } // namespace asio
104 } // namespace boost
105
106 #include <boost/asio/detail/pop_options.hpp>
107
108 #include <boost/asio/impl/dispatch.hpp>
109
110 #endif // BOOST_ASIO_DISPATCH_HPP