]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/experimental/detail/channel_send_functions.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / experimental / detail / channel_send_functions.hpp
1 //
2 // experimental/detail/channel_send_functions.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2022 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_EXPERIMENTAL_DETAIL_CHANNEL_SEND_FUNCTIONS_HPP
12 #define BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_SEND_FUNCTIONS_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/system/error_code.hpp>
22 #include <boost/asio/experimental/detail/channel_message.hpp>
23
24 #include <boost/asio/detail/push_options.hpp>
25
26 namespace boost {
27 namespace asio {
28 namespace experimental {
29 namespace detail {
30
31 template <typename Derived, typename Executor, typename... Signatures>
32 class channel_send_functions;
33
34 template <typename Derived, typename Executor, typename R, typename... Args>
35 class channel_send_functions<Derived, Executor, R(Args...)>
36 {
37 public:
38 template <typename... Args2>
39 typename enable_if<
40 is_constructible<detail::channel_message<R(Args...)>, int, Args2...>::value,
41 bool
42 >::type try_send(BOOST_ASIO_MOVE_ARG(Args2)... args)
43 {
44 typedef typename detail::channel_message<R(Args...)> message_type;
45 Derived* self = static_cast<Derived*>(this);
46 return self->service_->template try_send<message_type>(
47 self->impl_, BOOST_ASIO_MOVE_CAST(Args2)(args)...);
48 }
49
50 template <typename... Args2>
51 typename enable_if<
52 is_constructible<detail::channel_message<R(Args...)>, int, Args2...>::value,
53 std::size_t
54 >::type try_send_n(std::size_t count, BOOST_ASIO_MOVE_ARG(Args2)... args)
55 {
56 typedef typename detail::channel_message<R(Args...)> message_type;
57 Derived* self = static_cast<Derived*>(this);
58 return self->service_->template try_send_n<message_type>(
59 self->impl_, count, BOOST_ASIO_MOVE_CAST(Args2)(args)...);
60 }
61
62 template <
63 BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code))
64 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)>
65 auto async_send(Args... args,
66 BOOST_ASIO_MOVE_ARG(CompletionToken) token
67 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor))
68 {
69 typedef typename Derived::payload_type payload_type;
70 typedef typename detail::channel_message<R(Args...)> message_type;
71 Derived* self = static_cast<Derived*>(this);
72 return async_initiate<CompletionToken, void (boost::system::error_code)>(
73 typename Derived::initiate_async_send(self), token,
74 payload_type(message_type(0, BOOST_ASIO_MOVE_CAST(Args)(args)...)));
75 }
76 };
77
78 template <typename Derived, typename Executor,
79 typename R, typename... Args, typename... Signatures>
80 class channel_send_functions<Derived, Executor, R(Args...), Signatures...> :
81 public channel_send_functions<Derived, Executor, Signatures...>
82 {
83 public:
84 using channel_send_functions<Derived, Executor, Signatures...>::try_send;
85 using channel_send_functions<Derived, Executor, Signatures...>::async_send;
86
87 template <typename... Args2>
88 typename enable_if<
89 is_constructible<detail::channel_message<R(Args...)>, int, Args2...>::value,
90 bool
91 >::type try_send(BOOST_ASIO_MOVE_ARG(Args2)... args)
92 {
93 typedef typename detail::channel_message<R(Args...)> message_type;
94 Derived* self = static_cast<Derived*>(this);
95 return self->service_->template try_send<message_type>(
96 self->impl_, BOOST_ASIO_MOVE_CAST(Args2)(args)...);
97 }
98
99 template <typename... Args2>
100 typename enable_if<
101 is_constructible<detail::channel_message<R(Args...)>, int, Args2...>::value,
102 std::size_t
103 >::type try_send_n(std::size_t count, BOOST_ASIO_MOVE_ARG(Args2)... args)
104 {
105 typedef typename detail::channel_message<R(Args...)> message_type;
106 Derived* self = static_cast<Derived*>(this);
107 return self->service_->template try_send_n<message_type>(
108 self->impl_, count, BOOST_ASIO_MOVE_CAST(Args2)(args)...);
109 }
110
111 template <
112 BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code))
113 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)>
114 auto async_send(Args... args,
115 BOOST_ASIO_MOVE_ARG(CompletionToken) token
116 BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor))
117 {
118 typedef typename Derived::payload_type payload_type;
119 typedef typename detail::channel_message<R(Args...)> message_type;
120 Derived* self = static_cast<Derived*>(this);
121 return async_initiate<CompletionToken, void (boost::system::error_code)>(
122 typename Derived::initiate_async_send(self), token,
123 payload_type(message_type(0, BOOST_ASIO_MOVE_CAST(Args)(args)...)));
124 }
125 };
126
127 } // namespace detail
128 } // namespace experimental
129 } // namespace asio
130 } // namespace boost
131
132 #include <boost/asio/detail/pop_options.hpp>
133
134 #endif // BOOST_ASIO_EXPERIMENTAL_DETAIL_CHANNEL_SEND_FUNCTIONS_HPP