]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/impl/dispatch.hpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / boost / asio / impl / dispatch.hpp
CommitLineData
b32b8144
FG
1//
2// impl/dispatch.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_IMPL_DISPATCH_HPP
12#define BOOST_ASIO_IMPL_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/associated_allocator.hpp>
20#include <boost/asio/associated_executor.hpp>
21#include <boost/asio/detail/work_dispatcher.hpp>
22
23#include <boost/asio/detail/push_options.hpp>
24
25namespace boost {
26namespace asio {
27
28template <typename CompletionToken>
29BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
30 BOOST_ASIO_MOVE_ARG(CompletionToken) token)
31{
32 typedef BOOST_ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
33
34 async_completion<CompletionToken, void()> init(token);
35
36 typename associated_executor<handler>::type ex(
37 (get_associated_executor)(init.completion_handler));
38
39 typename associated_allocator<handler>::type alloc(
40 (get_associated_allocator)(init.completion_handler));
41
42 ex.dispatch(BOOST_ASIO_MOVE_CAST(handler)(init.completion_handler), alloc);
43
44 return init.result.get();
45}
46
47template <typename Executor, typename CompletionToken>
48BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
49 const Executor& ex, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
50 typename enable_if<is_executor<Executor>::value>::type*)
51{
52 typedef BOOST_ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
53
54 async_completion<CompletionToken, void()> init(token);
55
56 typename associated_allocator<handler>::type alloc(
57 (get_associated_allocator)(init.completion_handler));
58
59 ex.dispatch(detail::work_dispatcher<handler>(
60 init.completion_handler), alloc);
61
62 return init.result.get();
63}
64
65template <typename ExecutionContext, typename CompletionToken>
66inline BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
67 ExecutionContext& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
68 typename enable_if<is_convertible<
69 ExecutionContext&, execution_context&>::value>::type*)
70{
71 return (dispatch)(ctx.get_executor(),
72 BOOST_ASIO_MOVE_CAST(CompletionToken)(token));
73}
74
75} // namespace asio
76} // namespace boost
77
78#include <boost/asio/detail/pop_options.hpp>
79
80#endif // BOOST_ASIO_IMPL_DISPATCH_HPP