]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/dispatch.hpp
77eefcaefda325d64e0ee28c57ff3f4a1faaeb70
[ceph.git] / ceph / src / boost / boost / asio / dispatch.hpp
1 //
2 // dispatch.hpp
3 // ~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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 may be called from the current thread prior to
33 * returning from <tt>dispatch()</tt>. Otherwise, it is queued for execution.
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 <BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken>
54 BOOST_ASIO_INITFN_AUTO_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 may be called from the current thread prior to returning
61 * from <tt>dispatch()</tt>. Otherwise, it is queued for execution.
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,
88 BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken
89 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)>
90 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) dispatch(
91 const Executor& ex,
92 BOOST_ASIO_MOVE_ARG(CompletionToken) token
93 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor),
94 typename enable_if<is_executor<Executor>::value>::type* = 0);
95
96 /// Submits a completion token or function object for execution.
97 /**
98 * @returns <tt>dispatch(ctx.get_executor(),
99 * forward<CompletionToken>(token))</tt>.
100 */
101 template <typename ExecutionContext,
102 BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken
103 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
104 typename ExecutionContext::executor_type)>
105 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) dispatch(
106 ExecutionContext& ctx,
107 BOOST_ASIO_MOVE_ARG(CompletionToken) token
108 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(
109 typename ExecutionContext::executor_type),
110 typename enable_if<is_convertible<
111 ExecutionContext&, execution_context&>::value>::type* = 0);
112
113 } // namespace asio
114 } // namespace boost
115
116 #include <boost/asio/detail/pop_options.hpp>
117
118 #include <boost/asio/impl/dispatch.hpp>
119
120 #endif // BOOST_ASIO_DISPATCH_HPP