11 #ifndef ASIO_EXECUTION_OUTSTANDING_WORK_HPP 12 #define ASIO_EXECUTION_OUTSTANDING_WORK_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 19 #include "asio/detail/type_traits.hpp" 20 #include "asio/execution/executor.hpp" 21 #include "asio/execution/scheduler.hpp" 22 #include "asio/execution/sender.hpp" 23 #include "asio/is_applicable_property.hpp" 24 #include "asio/query.hpp" 25 #include "asio/traits/query_free.hpp" 26 #include "asio/traits/query_member.hpp" 27 #include "asio/traits/query_static_constexpr_member.hpp" 28 #include "asio/traits/static_query.hpp" 29 #include "asio/traits/static_require.hpp" 31 #include "asio/detail/push_options.hpp" 35 #if defined(GENERATING_DOCUMENTATION) 40 struct outstanding_work_t
45 static constexpr
bool is_applicable_property_v =
46 is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
49 static constexpr
bool is_requirable =
false;
52 static constexpr
bool is_preferable =
false;
55 typedef outstanding_work_t polymorphic_query_result_type;
64 static constexpr
bool is_applicable_property_v =
65 is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
68 static constexpr
bool is_requirable =
true;
71 static constexpr
bool is_preferable =
true;
74 typedef outstanding_work_t polymorphic_query_result_type;
77 constexpr untracked_t();
83 static constexpr outstanding_work_t value();
93 static constexpr
bool is_applicable_property_v =
94 is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
97 static constexpr
bool is_requirable =
true;
100 static constexpr
bool is_preferable =
true;
103 typedef outstanding_work_t polymorphic_query_result_type;
106 constexpr tracked_t();
112 static constexpr outstanding_work_t value();
117 static constexpr untracked_t untracked;
121 static constexpr tracked_t tracked;
124 constexpr outstanding_work_t();
127 constexpr outstanding_work_t(untracked_t);
130 constexpr outstanding_work_t(tracked_t);
133 friend constexpr
bool operator==(
134 const outstanding_work_t& a,
const outstanding_work_t& b) noexcept;
137 friend constexpr
bool operator!=(
138 const outstanding_work_t& a,
const outstanding_work_t& b) noexcept;
142 constexpr outstanding_work_t outstanding_work;
146 #else // defined(GENERATING_DOCUMENTATION) 150 namespace outstanding_work {
160 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 161 template <
typename T>
162 ASIO_STATIC_CONSTEXPR(
bool,
165 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 179 ASIO_CONSTEXPR outstanding_work_t(untracked_t)
184 ASIO_CONSTEXPR outstanding_work_t(tracked_t)
189 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 190 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 191 template <
typename T>
192 static ASIO_CONSTEXPR
194 T, outstanding_work_t>::result_type
198 T, outstanding_work_t
202 T, outstanding_work_t>::value();
205 template <
typename T>
206 static ASIO_CONSTEXPR
211 T, outstanding_work_t>::is_valid
214 >::type* = 0) ASIO_NOEXCEPT
219 template <
typename T>
220 static ASIO_CONSTEXPR
225 T, outstanding_work_t>::is_valid
229 >::type* = 0) ASIO_NOEXCEPT
234 template <
typename E,
235 typename T = decltype(outstanding_work_t::static_query<E>())>
236 static ASIO_CONSTEXPR
const T static_query_v
237 = outstanding_work_t::static_query<E>();
238 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 241 friend ASIO_CONSTEXPR
bool operator==(
242 const outstanding_work_t& a,
const outstanding_work_t& b)
244 return a.value_ == b.value_;
247 friend ASIO_CONSTEXPR
bool operator!=(
248 const outstanding_work_t& a,
const outstanding_work_t& b)
250 return a.value_ != b.value_;
260 template <
typename Executor>
261 friend ASIO_CONSTEXPR outstanding_work_t query(
266 #if !defined(__clang__) // Clang crashes if noexcept is used here. 267 #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified. 271 #else // defined(ASIO_MSVC) 274 #endif // defined(ASIO_MSVC) 275 #endif // !defined(__clang__) 277 return asio::query(ex, untracked_t());
280 template <
typename Executor>
281 friend ASIO_CONSTEXPR outstanding_work_t query(
287 #if !defined(__clang__) // Clang crashes if noexcept is used here. 288 #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified. 292 #else // defined(ASIO_MSVC) 295 #endif // defined(ASIO_MSVC) 296 #endif // !defined(__clang__) 298 return asio::query(ex, tracked_t());
301 ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(untracked_t, untracked);
302 ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(tracked_t, tracked);
304 #if !defined(ASIO_HAS_CONSTEXPR) 305 static const outstanding_work_t instance;
306 #endif // !defined(ASIO_HAS_CONSTEXPR) 312 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 313 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 314 template <
int I>
template <
typename E,
typename T>
316 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 319 #if !defined(ASIO_HAS_CONSTEXPR) 332 namespace outstanding_work {
337 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 338 template <
typename T>
339 ASIO_STATIC_CONSTEXPR(
bool,
342 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 352 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 353 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 354 template <
typename T>
355 static ASIO_CONSTEXPR
364 template <
typename T>
371 >::type* = 0) ASIO_NOEXCEPT
376 template <
typename E,
typename T = decltype(untracked_t::static_query<E>())>
377 static ASIO_CONSTEXPR
const T static_query_v
378 = untracked_t::static_query<E>();
379 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 387 friend ASIO_CONSTEXPR
bool operator==(
393 friend ASIO_CONSTEXPR
bool operator!=(
400 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 401 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 402 template <
int I>
template <
typename E,
typename T>
404 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 410 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 411 template <
typename T>
412 ASIO_STATIC_CONSTEXPR(
bool,
415 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 425 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 426 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 427 template <
typename T>
428 static ASIO_CONSTEXPR
437 template <
typename E,
typename T = decltype(tracked_t::static_query<E>())>
438 static ASIO_CONSTEXPR
const T static_query_v
439 = tracked_t::static_query<E>();
440 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 448 friend ASIO_CONSTEXPR
bool operator==(
454 friend ASIO_CONSTEXPR
bool operator!=(
461 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 462 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 463 template <
int I>
template <
typename E,
typename T>
465 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 473 #if defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) 474 constexpr outstanding_work_t outstanding_work;
475 #else // defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) 476 namespace {
static const outstanding_work_t&
477 outstanding_work = outstanding_work_t::instance; }
482 #if !defined(ASIO_HAS_VARIABLE_TEMPLATES) 484 template <
typename T>
486 : integral_constant<bool,
487 execution::is_executor<T>::value
488 || execution::is_sender<T>::value
489 || execution::is_scheduler<T>::value>
493 template <
typename T>
495 : integral_constant<bool,
496 execution::is_executor<T>::value
497 || execution::is_sender<T>::value
498 || execution::is_scheduler<T>::value>
502 template <
typename T>
504 : integral_constant<bool,
505 execution::is_executor<T>::value
506 || execution::is_sender<T>::value
507 || execution::is_scheduler<T>::value>
511 #endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES) 515 #if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 517 template <
typename T>
520 can_query<T, execution::outstanding_work_t::untracked_t>::value
523 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
524 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
530 template <
typename T>
533 !can_query<T, execution::outstanding_work_t::untracked_t>::value
534 && can_query<T, execution::outstanding_work_t::tracked_t>::value
537 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
538 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
544 #endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 546 #if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 547 || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 549 template <
typename T>
552 traits::query_static_constexpr_member<T,
553 execution::outstanding_work_t>::is_valid
556 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
557 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
562 static ASIO_CONSTEXPR result_type value()
569 template <
typename T>
572 !traits::query_static_constexpr_member<T,
573 execution::outstanding_work_t>::is_valid
574 && !traits::query_member<T,
575 execution::outstanding_work_t>::is_valid
576 && traits::static_query<T,
577 execution::outstanding_work_t::untracked_t>::is_valid
580 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
581 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
586 static ASIO_CONSTEXPR result_type value()
593 template <
typename T>
596 !traits::query_static_constexpr_member<T,
597 execution::outstanding_work_t>::is_valid
598 && !traits::query_member<T,
599 execution::outstanding_work_t>::is_valid
600 && !traits::static_query<T,
601 execution::outstanding_work_t::untracked_t>::is_valid
602 && traits::static_query<T,
603 execution::outstanding_work_t::tracked_t>::is_valid
606 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
607 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
612 static ASIO_CONSTEXPR result_type value()
619 template <
typename T>
622 traits::query_static_constexpr_member<T,
623 execution::outstanding_work_t::untracked_t>::is_valid
626 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
627 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
632 static ASIO_CONSTEXPR result_type value()
639 template <
typename T>
642 !traits::query_static_constexpr_member<T,
643 execution::outstanding_work_t::untracked_t>::is_valid
644 && !traits::query_member<T,
645 execution::outstanding_work_t::untracked_t>::is_valid
646 && !traits::query_free<T,
647 execution::outstanding_work_t::untracked_t>::is_valid
648 && !can_query<T, execution::outstanding_work_t::tracked_t>::value
651 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
652 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
656 static ASIO_CONSTEXPR result_type value()
658 return result_type();
662 template <
typename T>
665 traits::query_static_constexpr_member<T,
666 execution::outstanding_work_t::tracked_t>::is_valid
669 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
670 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
675 static ASIO_CONSTEXPR result_type value()
682 #endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 685 #if !defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT) 687 template <
typename T>
690 static_query<T, execution::outstanding_work_t::untracked_t>::is_valid
693 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
699 template <
typename T>
702 static_query<T, execution::outstanding_work_t::tracked_t>::is_valid
705 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
711 #endif // !defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT) 715 #endif // defined(GENERATING_DOCUMENTATION) 719 #include "asio/detail/pop_options.hpp" 721 #endif // ASIO_EXECUTION_OUTSTANDING_WORK_HPP Definition: static_require.hpp:37
Definition: any_executor.hpp:249
Definition: query.hpp:269
Definition: outstanding_work.hpp:253
The is_scheduler trait detects whether a type T satisfies the execution::scheduler concept...
Definition: scheduler.hpp:48
The is_sender trait detects whether a type T satisfies the execution::sender concept.
Definition: sender.hpp:183
Definition: query_member.hpp:38
Definition: static_query.hpp:42
Definition: type_traits.hpp:97
Definition: query.hpp:253
Definition: outstanding_work.hpp:158
Definition: outstanding_work.hpp:153
Definition: query_free.hpp:35
Definition: query_free.hpp:38
Definition: query_static_constexpr_member.hpp:42
Definition: any_executor.hpp:256
Definition: handler_work.hpp:37
Definition: is_applicable_property.hpp:46
Definition: any_io_executor.hpp:28
Definition: outstanding_work.hpp:152
The is_executor trait detects whether a type T satisfies the execution::executor concept.
Definition: executor.hpp:109