]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/any_io_executor.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / any_io_executor.hpp
CommitLineData
20effc67
TL
1//
2// any_io_executor.hpp
3// ~~~~~~~~~~~~~~~~~~~
4//
1e59de90 5// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
20effc67
TL
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_ANY_IO_EXECUTOR_HPP
12#define BOOST_ASIO_ANY_IO_EXECUTOR_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#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
20# include <boost/asio/executor.hpp>
21#else // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
22# include <boost/asio/execution.hpp>
23# include <boost/asio/execution_context.hpp>
24#endif // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
25
26#include <boost/asio/detail/push_options.hpp>
27
28namespace boost {
29namespace asio {
30
31#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
32
33typedef executor any_io_executor;
34
35#else // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
36
37/// Polymorphic executor type for use with I/O objects.
38/**
39 * The @c any_io_executor type is a polymorphic executor that supports the set
40 * of properties required by I/O objects. It is defined as the
41 * execution::any_executor class template parameterised as follows:
42 * @code execution::any_executor<
43 * execution::context_as_t<execution_context&>,
44 * execution::blocking_t::never_t,
45 * execution::prefer_only<execution::blocking_t::possibly_t>,
46 * execution::prefer_only<execution::outstanding_work_t::tracked_t>,
47 * execution::prefer_only<execution::outstanding_work_t::untracked_t>,
48 * execution::prefer_only<execution::relationship_t::fork_t>,
49 * execution::prefer_only<execution::relationship_t::continuation_t>
50 * > @endcode
51 */
1e59de90 52class any_io_executor :
20effc67 53#if defined(GENERATING_DOCUMENTATION)
1e59de90 54 public execution::any_executor<...>
20effc67 55#else // defined(GENERATING_DOCUMENTATION)
1e59de90
TL
56 public execution::any_executor<
57 execution::context_as_t<execution_context&>,
58 execution::blocking_t::never_t,
59 execution::prefer_only<execution::blocking_t::possibly_t>,
60 execution::prefer_only<execution::outstanding_work_t::tracked_t>,
61 execution::prefer_only<execution::outstanding_work_t::untracked_t>,
62 execution::prefer_only<execution::relationship_t::fork_t>,
63 execution::prefer_only<execution::relationship_t::continuation_t>
64 >
20effc67 65#endif // defined(GENERATING_DOCUMENTATION)
1e59de90
TL
66{
67public:
68#if !defined(GENERATING_DOCUMENTATION)
69 typedef execution::any_executor<
70 execution::context_as_t<execution_context&>,
71 execution::blocking_t::never_t,
72 execution::prefer_only<execution::blocking_t::possibly_t>,
73 execution::prefer_only<execution::outstanding_work_t::tracked_t>,
74 execution::prefer_only<execution::outstanding_work_t::untracked_t>,
75 execution::prefer_only<execution::relationship_t::fork_t>,
76 execution::prefer_only<execution::relationship_t::continuation_t>
77 > base_type;
78
79 typedef void supportable_properties_type(
80 execution::context_as_t<execution_context&>,
81 execution::blocking_t::never_t,
82 execution::prefer_only<execution::blocking_t::possibly_t>,
83 execution::prefer_only<execution::outstanding_work_t::tracked_t>,
84 execution::prefer_only<execution::outstanding_work_t::untracked_t>,
85 execution::prefer_only<execution::relationship_t::fork_t>,
86 execution::prefer_only<execution::relationship_t::continuation_t>
87 );
88#endif // !defined(GENERATING_DOCUMENTATION)
89
90 /// Default constructor.
91 BOOST_ASIO_DECL any_io_executor() BOOST_ASIO_NOEXCEPT;
92
93 /// Construct in an empty state. Equivalent effects to default constructor.
94 BOOST_ASIO_DECL any_io_executor(nullptr_t) BOOST_ASIO_NOEXCEPT;
95
96 /// Copy constructor.
97 BOOST_ASIO_DECL any_io_executor(const any_io_executor& e) BOOST_ASIO_NOEXCEPT;
98
99#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
100 /// Move constructor.
101 BOOST_ASIO_DECL any_io_executor(any_io_executor&& e) BOOST_ASIO_NOEXCEPT;
102#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
103
104 /// Construct to point to the same target as another any_executor.
105#if defined(GENERATING_DOCUMENTATION)
106 template <class... OtherSupportableProperties>
107 any_io_executor(execution::any_executor<OtherSupportableProperties...> e);
108#else // defined(GENERATING_DOCUMENTATION)
109 template <typename OtherAnyExecutor>
110 any_io_executor(OtherAnyExecutor e,
111 typename constraint<
112 conditional<
113 !is_same<OtherAnyExecutor, any_io_executor>::value
114 && is_base_of<execution::detail::any_executor_base,
115 OtherAnyExecutor>::value,
116 typename execution::detail::supportable_properties<
117 0, supportable_properties_type>::template
118 is_valid_target<OtherAnyExecutor>,
119 false_type
120 >::type::value
121 >::type = 0)
122 : base_type(BOOST_ASIO_MOVE_CAST(OtherAnyExecutor)(e))
123 {
124 }
125#endif // defined(GENERATING_DOCUMENTATION)
126
127 /// Construct a polymorphic wrapper for the specified executor.
128#if defined(GENERATING_DOCUMENTATION)
129 template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
130 any_io_executor(Executor e);
131#else // defined(GENERATING_DOCUMENTATION)
132 template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
133 any_io_executor(Executor e,
134 typename constraint<
135 conditional<
136 !is_same<Executor, any_io_executor>::value
137 && !is_base_of<execution::detail::any_executor_base,
138 Executor>::value,
139 execution::detail::is_valid_target_executor<
140 Executor, supportable_properties_type>,
141 false_type
142 >::type::value
143 >::type = 0)
144 : base_type(BOOST_ASIO_MOVE_CAST(Executor)(e))
145 {
146 }
147#endif // defined(GENERATING_DOCUMENTATION)
148
149 /// Assignment operator.
150 BOOST_ASIO_DECL any_io_executor& operator=(
151 const any_io_executor& e) BOOST_ASIO_NOEXCEPT;
152
153#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
154 /// Move assignment operator.
155 BOOST_ASIO_DECL any_io_executor& operator=(
156 any_io_executor&& e) BOOST_ASIO_NOEXCEPT;
157#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
158
159 /// Assignment operator that sets the polymorphic wrapper to the empty state.
160 BOOST_ASIO_DECL any_io_executor& operator=(nullptr_t);
161
162 /// Destructor.
163 BOOST_ASIO_DECL ~any_io_executor();
164
165 /// Swap targets with another polymorphic wrapper.
166 BOOST_ASIO_DECL void swap(any_io_executor& other) BOOST_ASIO_NOEXCEPT;
167
168 /// Obtain a polymorphic wrapper with the specified property.
169 /**
170 * Do not call this function directly. It is intended for use with the
171 * boost::asio::require and boost::asio::prefer customisation points.
172 *
173 * For example:
174 * @code any_io_executor ex = ...;
175 * auto ex2 = boost::asio::require(ex, execution::blocking.possibly); @endcode
176 */
177 template <typename Property>
178 any_io_executor require(const Property& p,
179 typename constraint<
180 traits::require_member<const base_type&, const Property&>::is_valid
181 >::type = 0) const
182 {
183 return static_cast<const base_type&>(*this).require(p);
184 }
185
186 /// Obtain a polymorphic wrapper with the specified property.
187 /**
188 * Do not call this function directly. It is intended for use with the
189 * boost::asio::prefer customisation point.
190 *
191 * For example:
192 * @code any_io_executor ex = ...;
193 * auto ex2 = boost::asio::prefer(ex, execution::blocking.possibly); @endcode
194 */
195 template <typename Property>
196 any_io_executor prefer(const Property& p,
197 typename constraint<
198 traits::prefer_member<const base_type&, const Property&>::is_valid
199 >::type = 0) const
200 {
201 return static_cast<const base_type&>(*this).prefer(p);
202 }
203};
204
205#if !defined(GENERATING_DOCUMENTATION)
206
207template <>
208BOOST_ASIO_DECL any_io_executor any_io_executor::require(
209 const execution::blocking_t::never_t&, int) const;
210
211template <>
212BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
213 const execution::blocking_t::possibly_t&, int) const;
214
215template <>
216BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
217 const execution::outstanding_work_t::tracked_t&, int) const;
218
219template <>
220BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
221 const execution::outstanding_work_t::untracked_t&, int) const;
222
223template <>
224BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
225 const execution::relationship_t::fork_t&, int) const;
226
227template <>
228BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
229 const execution::relationship_t::continuation_t&, int) const;
230
231namespace traits {
232
233#if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
234
235template <>
236struct equality_comparable<any_io_executor>
237{
238 static const bool is_valid = true;
239 static const bool is_noexcept = true;
240};
241
242#endif // !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
243
244#if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
245
246template <typename F>
247struct execute_member<any_io_executor, F>
248{
249 static const bool is_valid = true;
250 static const bool is_noexcept = false;
251 typedef void result_type;
252};
253
254#endif // !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
255
256#if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
257
258template <typename Prop>
259struct query_member<any_io_executor, Prop> :
260 query_member<any_io_executor::base_type, Prop>
261{
262};
263
264#endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
265
266#if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
267
268template <typename Prop>
269struct require_member<any_io_executor, Prop> :
270 require_member<any_io_executor::base_type, Prop>
271{
272 typedef any_io_executor result_type;
273};
274
275#endif // !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
276
277#if !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
278
279template <typename Prop>
280struct prefer_member<any_io_executor, Prop> :
281 prefer_member<any_io_executor::base_type, Prop>
282{
283 typedef any_io_executor result_type;
284};
285
286#endif // !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
287
288} // namespace traits
289
290#endif // !defined(GENERATING_DOCUMENTATION)
20effc67
TL
291
292#endif // defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
293
294} // namespace asio
295} // namespace boost
296
297#include <boost/asio/detail/pop_options.hpp>
298
1e59de90
TL
299#if defined(BOOST_ASIO_HEADER_ONLY) \
300 && !defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
301# include <boost/asio/impl/any_io_executor.ipp>
302#endif // defined(BOOST_ASIO_HEADER_ONLY)
303 // && !defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
304
20effc67 305#endif // BOOST_ASIO_ANY_IO_EXECUTOR_HPP