File indexing completed on 2025-12-16 09:43:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_EXECUTION_OUTSTANDING_WORK_HPP
0012 #define BOOST_ASIO_EXECUTION_OUTSTANDING_WORK_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/type_traits.hpp>
0020 #include <boost/asio/execution/executor.hpp>
0021 #include <boost/asio/is_applicable_property.hpp>
0022 #include <boost/asio/query.hpp>
0023 #include <boost/asio/traits/query_free.hpp>
0024 #include <boost/asio/traits/query_member.hpp>
0025 #include <boost/asio/traits/query_static_constexpr_member.hpp>
0026 #include <boost/asio/traits/static_query.hpp>
0027 #include <boost/asio/traits/static_require.hpp>
0028
0029 #include <boost/asio/detail/push_options.hpp>
0030
0031 namespace boost {
0032 namespace asio {
0033
0034 #if defined(GENERATING_DOCUMENTATION)
0035
0036 namespace execution {
0037
0038
0039 struct outstanding_work_t
0040 {
0041
0042 template <typename T>
0043 static constexpr bool is_applicable_property_v = is_executor_v<T>;
0044
0045
0046 static constexpr bool is_requirable = false;
0047
0048
0049 static constexpr bool is_preferable = false;
0050
0051
0052 typedef outstanding_work_t polymorphic_query_result_type;
0053
0054
0055
0056 struct untracked_t
0057 {
0058
0059 template <typename T>
0060 static constexpr bool is_applicable_property_v = is_executor_v<T>;
0061
0062
0063 static constexpr bool is_requirable = true;
0064
0065
0066 static constexpr bool is_preferable = true;
0067
0068
0069 typedef outstanding_work_t polymorphic_query_result_type;
0070
0071
0072 constexpr untracked_t();
0073
0074
0075
0076
0077
0078 static constexpr outstanding_work_t value();
0079 };
0080
0081
0082
0083 struct tracked_t
0084 {
0085
0086 template <typename T>
0087 static constexpr bool is_applicable_property_v = is_executor_v<T>;
0088
0089
0090 static constexpr bool is_requirable = true;
0091
0092
0093 static constexpr bool is_preferable = true;
0094
0095
0096 typedef outstanding_work_t polymorphic_query_result_type;
0097
0098
0099 constexpr tracked_t();
0100
0101
0102
0103
0104
0105 static constexpr outstanding_work_t value();
0106 };
0107
0108
0109
0110 static constexpr untracked_t untracked;
0111
0112
0113
0114 static constexpr tracked_t tracked;
0115
0116
0117 constexpr outstanding_work_t();
0118
0119
0120 constexpr outstanding_work_t(untracked_t);
0121
0122
0123 constexpr outstanding_work_t(tracked_t);
0124
0125
0126 friend constexpr bool operator==(
0127 const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
0128
0129
0130 friend constexpr bool operator!=(
0131 const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
0132 };
0133
0134
0135 constexpr outstanding_work_t outstanding_work;
0136
0137 }
0138
0139 #else
0140
0141 namespace execution {
0142 namespace detail {
0143 namespace outstanding_work {
0144
0145 template <int I> struct untracked_t;
0146 template <int I> struct tracked_t;
0147
0148 }
0149
0150 template <int I = 0>
0151 struct outstanding_work_t
0152 {
0153 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0154 template <typename T>
0155 static constexpr bool is_applicable_property_v = is_executor<T>::value;
0156 #endif
0157
0158 static constexpr bool is_requirable = false;
0159 static constexpr bool is_preferable = false;
0160 typedef outstanding_work_t polymorphic_query_result_type;
0161
0162 typedef detail::outstanding_work::untracked_t<I> untracked_t;
0163 typedef detail::outstanding_work::tracked_t<I> tracked_t;
0164
0165 constexpr outstanding_work_t()
0166 : value_(-1)
0167 {
0168 }
0169
0170 constexpr outstanding_work_t(untracked_t)
0171 : value_(0)
0172 {
0173 }
0174
0175 constexpr outstanding_work_t(tracked_t)
0176 : value_(1)
0177 {
0178 }
0179
0180 template <typename T>
0181 struct proxy
0182 {
0183 #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
0184 struct type
0185 {
0186 template <typename P>
0187 auto query(P&& p) const
0188 noexcept(
0189 noexcept(
0190 declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
0191 )
0192 )
0193 -> decltype(
0194 declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
0195 );
0196 };
0197 #else
0198 typedef T type;
0199 #endif
0200 };
0201
0202 template <typename T>
0203 struct static_proxy
0204 {
0205 #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
0206 struct type
0207 {
0208 template <typename P>
0209 static constexpr auto query(P&& p)
0210 noexcept(
0211 noexcept(
0212 conditional_t<true, T, P>::query(static_cast<P&&>(p))
0213 )
0214 )
0215 -> decltype(
0216 conditional_t<true, T, P>::query(static_cast<P&&>(p))
0217 )
0218 {
0219 return T::query(static_cast<P&&>(p));
0220 }
0221 };
0222 #else
0223 typedef T type;
0224 #endif
0225 };
0226
0227 template <typename T>
0228 struct query_member :
0229 traits::query_member<typename proxy<T>::type, outstanding_work_t> {};
0230
0231 template <typename T>
0232 struct query_static_constexpr_member :
0233 traits::query_static_constexpr_member<
0234 typename static_proxy<T>::type, outstanding_work_t> {};
0235
0236 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0237 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0238 template <typename T>
0239 static constexpr
0240 typename query_static_constexpr_member<T>::result_type
0241 static_query()
0242 noexcept(query_static_constexpr_member<T>::is_noexcept)
0243 {
0244 return query_static_constexpr_member<T>::value();
0245 }
0246
0247 template <typename T>
0248 static constexpr
0249 typename traits::static_query<T, untracked_t>::result_type
0250 static_query(
0251 enable_if_t<
0252 !query_static_constexpr_member<T>::is_valid
0253 >* = 0,
0254 enable_if_t<
0255 !query_member<T>::is_valid
0256 >* = 0,
0257 enable_if_t<
0258 traits::static_query<T, untracked_t>::is_valid
0259 >* = 0) noexcept
0260 {
0261 return traits::static_query<T, untracked_t>::value();
0262 }
0263
0264 template <typename T>
0265 static constexpr
0266 typename traits::static_query<T, tracked_t>::result_type
0267 static_query(
0268 enable_if_t<
0269 !query_static_constexpr_member<T>::is_valid
0270 >* = 0,
0271 enable_if_t<
0272 !query_member<T>::is_valid
0273 >* = 0,
0274 enable_if_t<
0275 !traits::static_query<T, untracked_t>::is_valid
0276 >* = 0,
0277 enable_if_t<
0278 traits::static_query<T, tracked_t>::is_valid
0279 >* = 0) noexcept
0280 {
0281 return traits::static_query<T, tracked_t>::value();
0282 }
0283
0284 template <typename E,
0285 typename T = decltype(outstanding_work_t::static_query<E>())>
0286 static constexpr const T static_query_v
0287 = outstanding_work_t::static_query<E>();
0288 #endif
0289
0290
0291 friend constexpr bool operator==(
0292 const outstanding_work_t& a, const outstanding_work_t& b)
0293 {
0294 return a.value_ == b.value_;
0295 }
0296
0297 friend constexpr bool operator!=(
0298 const outstanding_work_t& a, const outstanding_work_t& b)
0299 {
0300 return a.value_ != b.value_;
0301 }
0302
0303 struct convertible_from_outstanding_work_t
0304 {
0305 constexpr convertible_from_outstanding_work_t(outstanding_work_t)
0306 {
0307 }
0308 };
0309
0310 template <typename Executor>
0311 friend constexpr outstanding_work_t query(
0312 const Executor& ex, convertible_from_outstanding_work_t,
0313 enable_if_t<
0314 can_query<const Executor&, untracked_t>::value
0315 >* = 0)
0316 #if !defined(__clang__)
0317 #if defined(BOOST_ASIO_MSVC)
0318 noexcept(is_nothrow_query<const Executor&,
0319 outstanding_work_t<>::untracked_t>::value)
0320 #else
0321 noexcept(is_nothrow_query<const Executor&, untracked_t>::value)
0322 #endif
0323 #endif
0324 {
0325 return boost::asio::query(ex, untracked_t());
0326 }
0327
0328 template <typename Executor>
0329 friend constexpr outstanding_work_t query(
0330 const Executor& ex, convertible_from_outstanding_work_t,
0331 enable_if_t<
0332 !can_query<const Executor&, untracked_t>::value
0333 >* = 0,
0334 enable_if_t<
0335 can_query<const Executor&, tracked_t>::value
0336 >* = 0)
0337 #if !defined(__clang__)
0338 #if defined(BOOST_ASIO_MSVC)
0339 noexcept(is_nothrow_query<const Executor&,
0340 outstanding_work_t<>::tracked_t>::value)
0341 #else
0342 noexcept(is_nothrow_query<const Executor&, tracked_t>::value)
0343 #endif
0344 #endif
0345 {
0346 return boost::asio::query(ex, tracked_t());
0347 }
0348
0349 BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(untracked_t, untracked);
0350 BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(tracked_t, tracked);
0351
0352 private:
0353 int value_;
0354 };
0355
0356 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0357 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0358 template <int I> template <typename E, typename T>
0359 const T outstanding_work_t<I>::static_query_v;
0360 #endif
0361
0362
0363 template <int I>
0364 const typename outstanding_work_t<I>::untracked_t
0365 outstanding_work_t<I>::untracked;
0366
0367 template <int I>
0368 const typename outstanding_work_t<I>::tracked_t
0369 outstanding_work_t<I>::tracked;
0370
0371 namespace outstanding_work {
0372
0373 template <int I = 0>
0374 struct untracked_t
0375 {
0376 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0377 template <typename T>
0378 static constexpr bool is_applicable_property_v = is_executor<T>::value;
0379 #endif
0380
0381 static constexpr bool is_requirable = true;
0382 static constexpr bool is_preferable = true;
0383 typedef outstanding_work_t<I> polymorphic_query_result_type;
0384
0385 constexpr untracked_t()
0386 {
0387 }
0388
0389 template <typename T>
0390 struct query_member :
0391 traits::query_member<
0392 typename outstanding_work_t<I>::template proxy<T>::type, untracked_t> {};
0393
0394 template <typename T>
0395 struct query_static_constexpr_member :
0396 traits::query_static_constexpr_member<
0397 typename outstanding_work_t<I>::template static_proxy<T>::type,
0398 untracked_t> {};
0399
0400 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0401 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0402 template <typename T>
0403 static constexpr
0404 typename query_static_constexpr_member<T>::result_type
0405 static_query()
0406 noexcept(query_static_constexpr_member<T>::is_noexcept)
0407 {
0408 return query_static_constexpr_member<T>::value();
0409 }
0410
0411 template <typename T>
0412 static constexpr untracked_t static_query(
0413 enable_if_t<
0414 !query_static_constexpr_member<T>::is_valid
0415 >* = 0,
0416 enable_if_t<
0417 !query_member<T>::is_valid
0418 >* = 0,
0419 enable_if_t<
0420 !traits::query_free<T, untracked_t>::is_valid
0421 >* = 0,
0422 enable_if_t<
0423 !can_query<T, tracked_t<I>>::value
0424 >* = 0) noexcept
0425 {
0426 return untracked_t();
0427 }
0428
0429 template <typename E, typename T = decltype(untracked_t::static_query<E>())>
0430 static constexpr const T static_query_v = untracked_t::static_query<E>();
0431 #endif
0432
0433
0434 static constexpr outstanding_work_t<I> value()
0435 {
0436 return untracked_t();
0437 }
0438
0439 friend constexpr bool operator==(const untracked_t&, const untracked_t&)
0440 {
0441 return true;
0442 }
0443
0444 friend constexpr bool operator!=(const untracked_t&, const untracked_t&)
0445 {
0446 return false;
0447 }
0448
0449 friend constexpr bool operator==(const untracked_t&, const tracked_t<I>&)
0450 {
0451 return false;
0452 }
0453
0454 friend constexpr bool operator!=(const untracked_t&, const tracked_t<I>&)
0455 {
0456 return true;
0457 }
0458 };
0459
0460 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0461 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0462 template <int I> template <typename E, typename T>
0463 const T untracked_t<I>::static_query_v;
0464 #endif
0465
0466
0467 template <int I = 0>
0468 struct tracked_t
0469 {
0470 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0471 template <typename T>
0472 static constexpr bool is_applicable_property_v = is_executor<T>::value;
0473 #endif
0474
0475 static constexpr bool is_requirable = true;
0476 static constexpr bool is_preferable = true;
0477 typedef outstanding_work_t<I> polymorphic_query_result_type;
0478
0479 constexpr tracked_t()
0480 {
0481 }
0482
0483 template <typename T>
0484 struct query_member :
0485 traits::query_member<
0486 typename outstanding_work_t<I>::template proxy<T>::type, tracked_t> {};
0487
0488 template <typename T>
0489 struct query_static_constexpr_member :
0490 traits::query_static_constexpr_member<
0491 typename outstanding_work_t<I>::template static_proxy<T>::type,
0492 tracked_t> {};
0493
0494 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0495 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0496 template <typename T>
0497 static constexpr
0498 typename query_static_constexpr_member<T>::result_type
0499 static_query()
0500 noexcept(query_static_constexpr_member<T>::is_noexcept)
0501 {
0502 return query_static_constexpr_member<T>::value();
0503 }
0504
0505 template <typename E, typename T = decltype(tracked_t::static_query<E>())>
0506 static constexpr const T static_query_v = tracked_t::static_query<E>();
0507 #endif
0508
0509
0510 static constexpr outstanding_work_t<I> value()
0511 {
0512 return tracked_t();
0513 }
0514
0515 friend constexpr bool operator==(const tracked_t&, const tracked_t&)
0516 {
0517 return true;
0518 }
0519
0520 friend constexpr bool operator!=(const tracked_t&, const tracked_t&)
0521 {
0522 return false;
0523 }
0524
0525 friend constexpr bool operator==(const tracked_t&, const untracked_t<I>&)
0526 {
0527 return false;
0528 }
0529
0530 friend constexpr bool operator!=(const tracked_t&, const untracked_t<I>&)
0531 {
0532 return true;
0533 }
0534 };
0535
0536 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0537 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0538 template <int I> template <typename E, typename T>
0539 const T tracked_t<I>::static_query_v;
0540 #endif
0541
0542
0543 }
0544 }
0545
0546 typedef detail::outstanding_work_t<> outstanding_work_t;
0547
0548 BOOST_ASIO_INLINE_VARIABLE constexpr outstanding_work_t outstanding_work;
0549
0550 }
0551
0552 #if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0553
0554 template <typename T>
0555 struct is_applicable_property<T, execution::outstanding_work_t>
0556 : integral_constant<bool, execution::is_executor<T>::value>
0557 {
0558 };
0559
0560 template <typename T>
0561 struct is_applicable_property<T, execution::outstanding_work_t::untracked_t>
0562 : integral_constant<bool, execution::is_executor<T>::value>
0563 {
0564 };
0565
0566 template <typename T>
0567 struct is_applicable_property<T, execution::outstanding_work_t::tracked_t>
0568 : integral_constant<bool, execution::is_executor<T>::value>
0569 {
0570 };
0571
0572 #endif
0573
0574 namespace traits {
0575
0576 #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
0577
0578 template <typename T>
0579 struct query_free_default<T, execution::outstanding_work_t,
0580 enable_if_t<
0581 can_query<T, execution::outstanding_work_t::untracked_t>::value
0582 >>
0583 {
0584 static constexpr bool is_valid = true;
0585 static constexpr bool is_noexcept =
0586 is_nothrow_query<T, execution::outstanding_work_t::untracked_t>::value;
0587
0588 typedef execution::outstanding_work_t result_type;
0589 };
0590
0591 template <typename T>
0592 struct query_free_default<T, execution::outstanding_work_t,
0593 enable_if_t<
0594 !can_query<T, execution::outstanding_work_t::untracked_t>::value
0595 && can_query<T, execution::outstanding_work_t::tracked_t>::value
0596 >>
0597 {
0598 static constexpr bool is_valid = true;
0599 static constexpr bool is_noexcept =
0600 is_nothrow_query<T, execution::outstanding_work_t::tracked_t>::value;
0601
0602 typedef execution::outstanding_work_t result_type;
0603 };
0604
0605 #endif
0606
0607 #if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0608 || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0609
0610 template <typename T>
0611 struct static_query<T, execution::outstanding_work_t,
0612 enable_if_t<
0613 execution::detail::outstanding_work_t<0>::
0614 query_static_constexpr_member<T>::is_valid
0615 >>
0616 {
0617 static constexpr bool is_valid = true;
0618 static constexpr bool is_noexcept = true;
0619
0620 typedef typename execution::detail::outstanding_work_t<0>::
0621 query_static_constexpr_member<T>::result_type result_type;
0622
0623 static constexpr result_type value()
0624 {
0625 return execution::detail::outstanding_work_t<0>::
0626 query_static_constexpr_member<T>::value();
0627 }
0628 };
0629
0630 template <typename T>
0631 struct static_query<T, execution::outstanding_work_t,
0632 enable_if_t<
0633 !execution::detail::outstanding_work_t<0>::
0634 query_static_constexpr_member<T>::is_valid
0635 && !execution::detail::outstanding_work_t<0>::
0636 query_member<T>::is_valid
0637 && traits::static_query<T,
0638 execution::outstanding_work_t::untracked_t>::is_valid
0639 >>
0640 {
0641 static constexpr bool is_valid = true;
0642 static constexpr bool is_noexcept = true;
0643
0644 typedef typename traits::static_query<T,
0645 execution::outstanding_work_t::untracked_t>::result_type result_type;
0646
0647 static constexpr result_type value()
0648 {
0649 return traits::static_query<T,
0650 execution::outstanding_work_t::untracked_t>::value();
0651 }
0652 };
0653
0654 template <typename T>
0655 struct static_query<T, execution::outstanding_work_t,
0656 enable_if_t<
0657 !execution::detail::outstanding_work_t<0>::
0658 query_static_constexpr_member<T>::is_valid
0659 && !execution::detail::outstanding_work_t<0>::
0660 query_member<T>::is_valid
0661 && !traits::static_query<T,
0662 execution::outstanding_work_t::untracked_t>::is_valid
0663 && traits::static_query<T,
0664 execution::outstanding_work_t::tracked_t>::is_valid
0665 >>
0666 {
0667 static constexpr bool is_valid = true;
0668 static constexpr bool is_noexcept = true;
0669
0670 typedef typename traits::static_query<T,
0671 execution::outstanding_work_t::tracked_t>::result_type result_type;
0672
0673 static constexpr result_type value()
0674 {
0675 return traits::static_query<T,
0676 execution::outstanding_work_t::tracked_t>::value();
0677 }
0678 };
0679
0680 template <typename T>
0681 struct static_query<T, execution::outstanding_work_t::untracked_t,
0682 enable_if_t<
0683 execution::detail::outstanding_work::untracked_t<0>::
0684 query_static_constexpr_member<T>::is_valid
0685 >>
0686 {
0687 static constexpr bool is_valid = true;
0688 static constexpr bool is_noexcept = true;
0689
0690 typedef typename execution::detail::outstanding_work::untracked_t<0>::
0691 query_static_constexpr_member<T>::result_type result_type;
0692
0693 static constexpr result_type value()
0694 {
0695 return execution::detail::outstanding_work::untracked_t<0>::
0696 query_static_constexpr_member<T>::value();
0697 }
0698 };
0699
0700 template <typename T>
0701 struct static_query<T, execution::outstanding_work_t::untracked_t,
0702 enable_if_t<
0703 !execution::detail::outstanding_work::untracked_t<0>::
0704 query_static_constexpr_member<T>::is_valid
0705 && !execution::detail::outstanding_work::untracked_t<0>::
0706 query_member<T>::is_valid
0707 && !traits::query_free<T,
0708 execution::outstanding_work_t::untracked_t>::is_valid
0709 && !can_query<T, execution::outstanding_work_t::tracked_t>::value
0710 >>
0711 {
0712 static constexpr bool is_valid = true;
0713 static constexpr bool is_noexcept = true;
0714
0715 typedef execution::outstanding_work_t::untracked_t result_type;
0716
0717 static constexpr result_type value()
0718 {
0719 return result_type();
0720 }
0721 };
0722
0723 template <typename T>
0724 struct static_query<T, execution::outstanding_work_t::tracked_t,
0725 enable_if_t<
0726 execution::detail::outstanding_work::tracked_t<0>::
0727 query_static_constexpr_member<T>::is_valid
0728 >>
0729 {
0730 static constexpr bool is_valid = true;
0731 static constexpr bool is_noexcept = true;
0732
0733 typedef typename execution::detail::outstanding_work::tracked_t<0>::
0734 query_static_constexpr_member<T>::result_type result_type;
0735
0736 static constexpr result_type value()
0737 {
0738 return execution::detail::outstanding_work::tracked_t<0>::
0739 query_static_constexpr_member<T>::value();
0740 }
0741 };
0742
0743 #endif
0744
0745
0746 }
0747
0748 #endif
0749
0750 }
0751 }
0752
0753 #include <boost/asio/detail/pop_options.hpp>
0754
0755 #endif