File indexing completed on 2025-12-15 09:44:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_ANY_IO_EXECUTOR_HPP
0012 #define BOOST_ASIO_ANY_IO_EXECUTOR_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0020 # include <boost/asio/executor.hpp>
0021 #else
0022 # include <boost/asio/execution.hpp>
0023 # include <boost/asio/execution_context.hpp>
0024 #endif
0025
0026 #include <boost/asio/detail/push_options.hpp>
0027
0028 namespace boost {
0029 namespace asio {
0030
0031 #if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0032
0033 typedef executor any_io_executor;
0034
0035 #else
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 class any_io_executor :
0053 #if defined(GENERATING_DOCUMENTATION)
0054 public execution::any_executor<...>
0055 #else
0056 public execution::any_executor<
0057 execution::context_as_t<execution_context&>,
0058 execution::blocking_t::never_t,
0059 execution::prefer_only<execution::blocking_t::possibly_t>,
0060 execution::prefer_only<execution::outstanding_work_t::tracked_t>,
0061 execution::prefer_only<execution::outstanding_work_t::untracked_t>,
0062 execution::prefer_only<execution::relationship_t::fork_t>,
0063 execution::prefer_only<execution::relationship_t::continuation_t>
0064 >
0065 #endif
0066 {
0067 public:
0068 #if !defined(GENERATING_DOCUMENTATION)
0069 typedef execution::any_executor<
0070 execution::context_as_t<execution_context&>,
0071 execution::blocking_t::never_t,
0072 execution::prefer_only<execution::blocking_t::possibly_t>,
0073 execution::prefer_only<execution::outstanding_work_t::tracked_t>,
0074 execution::prefer_only<execution::outstanding_work_t::untracked_t>,
0075 execution::prefer_only<execution::relationship_t::fork_t>,
0076 execution::prefer_only<execution::relationship_t::continuation_t>
0077 > base_type;
0078
0079 typedef void supportable_properties_type(
0080 execution::context_as_t<execution_context&>,
0081 execution::blocking_t::never_t,
0082 execution::prefer_only<execution::blocking_t::possibly_t>,
0083 execution::prefer_only<execution::outstanding_work_t::tracked_t>,
0084 execution::prefer_only<execution::outstanding_work_t::untracked_t>,
0085 execution::prefer_only<execution::relationship_t::fork_t>,
0086 execution::prefer_only<execution::relationship_t::continuation_t>
0087 );
0088 #endif
0089
0090
0091 BOOST_ASIO_DECL any_io_executor() noexcept;
0092
0093
0094 BOOST_ASIO_DECL any_io_executor(nullptr_t) noexcept;
0095
0096
0097 BOOST_ASIO_DECL any_io_executor(const any_io_executor& e) noexcept;
0098
0099
0100 BOOST_ASIO_DECL any_io_executor(any_io_executor&& e) noexcept;
0101
0102
0103 #if defined(GENERATING_DOCUMENTATION)
0104 template <class... OtherSupportableProperties>
0105 any_io_executor(execution::any_executor<OtherSupportableProperties...> e);
0106 #else
0107 template <typename OtherAnyExecutor>
0108 any_io_executor(OtherAnyExecutor e,
0109 constraint_t<
0110 conditional_t<
0111 !is_same<OtherAnyExecutor, any_io_executor>::value
0112 && is_base_of<execution::detail::any_executor_base,
0113 OtherAnyExecutor>::value,
0114 typename execution::detail::supportable_properties<
0115 0, supportable_properties_type>::template
0116 is_valid_target<OtherAnyExecutor>,
0117 false_type
0118 >::value
0119 > = 0)
0120 : base_type(static_cast<OtherAnyExecutor&&>(e))
0121 {
0122 }
0123 #endif
0124
0125
0126 #if defined(GENERATING_DOCUMENTATION)
0127 template <class... OtherSupportableProperties>
0128 any_io_executor(std::nothrow_t,
0129 execution::any_executor<OtherSupportableProperties...> e);
0130 #else
0131 template <typename OtherAnyExecutor>
0132 any_io_executor(std::nothrow_t, OtherAnyExecutor e,
0133 constraint_t<
0134 conditional_t<
0135 !is_same<OtherAnyExecutor, any_io_executor>::value
0136 && is_base_of<execution::detail::any_executor_base,
0137 OtherAnyExecutor>::value,
0138 typename execution::detail::supportable_properties<
0139 0, supportable_properties_type>::template
0140 is_valid_target<OtherAnyExecutor>,
0141 false_type
0142 >::value
0143 > = 0) noexcept
0144 : base_type(std::nothrow, static_cast<OtherAnyExecutor&&>(e))
0145 {
0146 }
0147 #endif
0148
0149
0150 BOOST_ASIO_DECL any_io_executor(std::nothrow_t,
0151 const any_io_executor& e) noexcept;
0152
0153
0154 BOOST_ASIO_DECL any_io_executor(std::nothrow_t, any_io_executor&& e) noexcept;
0155
0156
0157 #if defined(GENERATING_DOCUMENTATION)
0158 template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0159 any_io_executor(Executor e);
0160 #else
0161 template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0162 any_io_executor(Executor e,
0163 constraint_t<
0164 conditional_t<
0165 !is_same<Executor, any_io_executor>::value
0166 && !is_base_of<execution::detail::any_executor_base,
0167 Executor>::value,
0168 execution::detail::is_valid_target_executor<
0169 Executor, supportable_properties_type>,
0170 false_type
0171 >::value
0172 > = 0)
0173 : base_type(static_cast<Executor&&>(e))
0174 {
0175 }
0176 #endif
0177
0178
0179 #if defined(GENERATING_DOCUMENTATION)
0180 template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0181 any_io_executor(std::nothrow_t, Executor e);
0182 #else
0183 template <BOOST_ASIO_EXECUTION_EXECUTOR Executor>
0184 any_io_executor(std::nothrow_t, Executor e,
0185 constraint_t<
0186 conditional_t<
0187 !is_same<Executor, any_io_executor>::value
0188 && !is_base_of<execution::detail::any_executor_base,
0189 Executor>::value,
0190 execution::detail::is_valid_target_executor<
0191 Executor, supportable_properties_type>,
0192 false_type
0193 >::value
0194 > = 0) noexcept
0195 : base_type(std::nothrow, static_cast<Executor&&>(e))
0196 {
0197 }
0198 #endif
0199
0200
0201 BOOST_ASIO_DECL any_io_executor& operator=(
0202 const any_io_executor& e) noexcept;
0203
0204
0205 BOOST_ASIO_DECL any_io_executor& operator=(any_io_executor&& e) noexcept;
0206
0207
0208 BOOST_ASIO_DECL any_io_executor& operator=(nullptr_t);
0209
0210
0211 BOOST_ASIO_DECL ~any_io_executor();
0212
0213
0214 BOOST_ASIO_DECL void swap(any_io_executor& other) noexcept;
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225 template <typename Property>
0226 any_io_executor require(const Property& p,
0227 constraint_t<
0228 traits::require_member<const base_type&, const Property&>::is_valid
0229 > = 0) const
0230 {
0231 return static_cast<const base_type&>(*this).require(p);
0232 }
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243 template <typename Property>
0244 any_io_executor prefer(const Property& p,
0245 constraint_t<
0246 traits::prefer_member<const base_type&, const Property&>::is_valid
0247 > = 0) const
0248 {
0249 return static_cast<const base_type&>(*this).prefer(p);
0250 }
0251 };
0252
0253 #if !defined(GENERATING_DOCUMENTATION)
0254
0255 template <>
0256 BOOST_ASIO_DECL any_io_executor any_io_executor::require(
0257 const execution::blocking_t::never_t&, int) const;
0258
0259 template <>
0260 BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
0261 const execution::blocking_t::possibly_t&, int) const;
0262
0263 template <>
0264 BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
0265 const execution::outstanding_work_t::tracked_t&, int) const;
0266
0267 template <>
0268 BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
0269 const execution::outstanding_work_t::untracked_t&, int) const;
0270
0271 template <>
0272 BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
0273 const execution::relationship_t::fork_t&, int) const;
0274
0275 template <>
0276 BOOST_ASIO_DECL any_io_executor any_io_executor::prefer(
0277 const execution::relationship_t::continuation_t&, int) const;
0278
0279 namespace traits {
0280
0281 #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
0282
0283 template <>
0284 struct equality_comparable<any_io_executor>
0285 {
0286 static const bool is_valid = true;
0287 static const bool is_noexcept = true;
0288 };
0289
0290 #endif
0291
0292 #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
0293
0294 template <typename F>
0295 struct execute_member<any_io_executor, F>
0296 {
0297 static const bool is_valid = true;
0298 static const bool is_noexcept = false;
0299 typedef void result_type;
0300 };
0301
0302 #endif
0303
0304 #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
0305
0306 template <typename Prop>
0307 struct query_member<any_io_executor, Prop> :
0308 query_member<any_io_executor::base_type, Prop>
0309 {
0310 };
0311
0312 #endif
0313
0314 #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
0315
0316 template <typename Prop>
0317 struct require_member<any_io_executor, Prop> :
0318 require_member<any_io_executor::base_type, Prop>
0319 {
0320 typedef any_io_executor result_type;
0321 };
0322
0323 #endif
0324
0325 #if !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
0326
0327 template <typename Prop>
0328 struct prefer_member<any_io_executor, Prop> :
0329 prefer_member<any_io_executor::base_type, Prop>
0330 {
0331 typedef any_io_executor result_type;
0332 };
0333
0334 #endif
0335
0336 }
0337
0338 #endif
0339
0340 #endif
0341
0342 }
0343 }
0344
0345 #include <boost/asio/detail/pop_options.hpp>
0346
0347 #if defined(BOOST_ASIO_HEADER_ONLY) \
0348 && !defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
0349 # include <boost/asio/impl/any_io_executor.ipp>
0350 #endif
0351
0352
0353 #endif