]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/post.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / asio / post.hpp
CommitLineData
b32b8144
FG
1//
2// post.hpp
3// ~~~~~~~~
4//
f67539c2 5// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
b32b8144
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 BOOST_ASIO_POST_HPP
12#define BOOST_ASIO_POST_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>
20effc67 22#include <boost/asio/execution/executor.hpp>
b32b8144
FG
23#include <boost/asio/is_executor.hpp>
24
25#include <boost/asio/detail/push_options.hpp>
26
27namespace boost {
28namespace asio {
29
30/// Submits a completion token or function object for execution.
31/**
32 * This function submits an object for execution using the object's associated
33 * executor. The function object is queued for execution, and is never called
34 * from the current thread prior to returning from <tt>post()</tt>.
35 *
92f5a8d4
TL
36 * The use of @c post(), rather than @ref defer(), indicates the caller's
37 * preference that the function object be eagerly queued for execution.
38 *
b32b8144
FG
39 * This function has the following effects:
40 *
41 * @li Constructs a function object handler of type @c Handler, initialized
42 * with <tt>handler(forward<CompletionToken>(token))</tt>.
43 *
44 * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
45 * initializing the object as <tt>result(handler)</tt>.
46 *
47 * @li Obtains the handler's associated executor object @c ex by performing
48 * <tt>get_associated_executor(handler)</tt>.
49 *
50 * @li Obtains the handler's associated allocator object @c alloc by performing
51 * <tt>get_associated_allocator(handler)</tt>.
52 *
53 * @li Performs <tt>ex.post(std::move(handler), alloc)</tt>.
54 *
55 * @li Returns <tt>result.get()</tt>.
56 */
92f5a8d4
TL
57template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken>
58BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) post(
b32b8144
FG
59 BOOST_ASIO_MOVE_ARG(CompletionToken) token);
60
61/// Submits a completion token or function object for execution.
62/**
63 * This function submits an object for execution using the specified executor.
64 * The function object is queued for execution, and is never called from the
65 * current thread prior to returning from <tt>post()</tt>.
66 *
92f5a8d4
TL
67 * The use of @c post(), rather than @ref defer(), indicates the caller's
68 * preference that the function object be eagerly queued for execution.
69 *
b32b8144
FG
70 * This function has the following effects:
71 *
72 * @li Constructs a function object handler of type @c Handler, initialized
73 * with <tt>handler(forward<CompletionToken>(token))</tt>.
74 *
75 * @li Constructs an object @c result of type <tt>async_result<Handler></tt>,
76 * initializing the object as <tt>result(handler)</tt>.
77 *
78 * @li Obtains the handler's associated executor object @c ex1 by performing
79 * <tt>get_associated_executor(handler)</tt>.
80 *
81 * @li Creates a work object @c w by performing <tt>make_work(ex1)</tt>.
82 *
83 * @li Obtains the handler's associated allocator object @c alloc by performing
84 * <tt>get_associated_allocator(handler)</tt>.
85 *
86 * @li Constructs a function object @c f with a function call operator that
87 * performs <tt>ex1.dispatch(std::move(handler), alloc)</tt> followed by
88 * <tt>w.reset()</tt>.
89 *
90 * @li Performs <tt>Executor(ex).post(std::move(f), alloc)</tt>.
91 *
92 * @li Returns <tt>result.get()</tt>.
93 */
92f5a8d4
TL
94template <typename Executor,
95 BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken
96 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)>
97BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) post(
98 const Executor& ex,
99 BOOST_ASIO_MOVE_ARG(CompletionToken) token
100 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor),
20effc67
TL
101 typename enable_if<
102 execution::is_executor<Executor>::value || is_executor<Executor>::value
103 >::type* = 0);
b32b8144
FG
104
105/// Submits a completion token or function object for execution.
106/**
107 * @returns <tt>post(ctx.get_executor(), forward<CompletionToken>(token))</tt>.
108 */
92f5a8d4
TL
109template <typename ExecutionContext,
110 BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken
111 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
112 typename ExecutionContext::executor_type)>
113BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) post(
114 ExecutionContext& ctx,
115 BOOST_ASIO_MOVE_ARG(CompletionToken) token
116 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(
117 typename ExecutionContext::executor_type),
b32b8144
FG
118 typename enable_if<is_convertible<
119 ExecutionContext&, execution_context&>::value>::type* = 0);
120
121} // namespace asio
122} // namespace boost
123
124#include <boost/asio/detail/pop_options.hpp>
125
126#include <boost/asio/impl/post.hpp>
127
128#endif // BOOST_ASIO_POST_HPP