]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/defer.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / asio / defer.hpp
CommitLineData
b32b8144
FG
1//
2// defer.hpp
3// ~~~~~~~~~
4//
11fdf7f2 5// Copyright (c) 2003-2018 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_DEFER_HPP
12#define BOOST_ASIO_DEFER_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
26namespace boost {
27namespace 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>defer()</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.defer(std::move(handler), alloc)</tt>.
50 *
51 * @li Returns <tt>result.get()</tt>.
52 */
53template <typename CompletionToken>
54BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
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>defer()</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).defer(std::move(f), alloc)</tt>.
84 *
85 * @li Returns <tt>result.get()</tt>.
86 */
87template <typename Executor, typename CompletionToken>
88BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
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>defer(ctx.get_executor(), forward<CompletionToken>(token))</tt>.
95 */
96template <typename ExecutionContext, typename CompletionToken>
97BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
98 ExecutionContext& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
99 typename enable_if<is_convertible<
100 ExecutionContext&, execution_context&>::value>::type* = 0);
101
102} // namespace asio
103} // namespace boost
104
105#include <boost/asio/detail/pop_options.hpp>
106
107#include <boost/asio/impl/defer.hpp>
108
109#endif // BOOST_ASIO_DEFER_HPP