11 #ifndef ASIO_EXECUTION_MAPPING_HPP 12 #define ASIO_EXECUTION_MAPPING_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) 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 mapping_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 mapping_t polymorphic_query_result_type;
83 static constexpr mapping_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 mapping_t polymorphic_query_result_type;
106 constexpr new_thread_t();
112 static constexpr mapping_t value();
121 template <
typename T>
122 static constexpr
bool is_applicable_property_v =
123 is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
126 static constexpr
bool is_requirable =
true;
129 static constexpr
bool is_preferable =
true;
132 typedef mapping_t polymorphic_query_result_type;
141 static constexpr mapping_t value();
145 static constexpr thread_t thread;
148 static constexpr new_thread_t new_thread;
151 static constexpr other_t other;
154 constexpr mapping_t();
157 constexpr mapping_t(thread_t);
160 constexpr mapping_t(new_thread_t);
163 constexpr mapping_t(other_t);
166 friend constexpr
bool operator==(
167 const mapping_t& a,
const mapping_t& b) noexcept;
170 friend constexpr
bool operator!=(
171 const mapping_t& a,
const mapping_t& b) noexcept;
175 constexpr mapping_t mapping;
179 #else // defined(GENERATING_DOCUMENTATION) 194 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 195 template <
typename T>
196 ASIO_STATIC_CONSTEXPR(
bool,
199 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 214 ASIO_CONSTEXPR mapping_t(thread_t)
219 ASIO_CONSTEXPR mapping_t(new_thread_t)
224 ASIO_CONSTEXPR mapping_t(other_t)
229 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 230 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 231 template <
typename T>
232 static ASIO_CONSTEXPR
241 template <
typename T>
242 static ASIO_CONSTEXPR
249 >::type* = 0) ASIO_NOEXCEPT
254 template <
typename T>
255 static ASIO_CONSTEXPR
263 >::type* = 0) ASIO_NOEXCEPT
268 template <
typename T>
269 static ASIO_CONSTEXPR
278 >::type* = 0) ASIO_NOEXCEPT
283 template <
typename E,
typename T = decltype(mapping_t::static_query<E>())>
284 static ASIO_CONSTEXPR
const T static_query_v
285 = mapping_t::static_query<E>();
286 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 289 friend ASIO_CONSTEXPR
bool operator==(
290 const mapping_t& a,
const mapping_t& b)
292 return a.value_ == b.value_;
295 friend ASIO_CONSTEXPR
bool operator!=(
296 const mapping_t& a,
const mapping_t& b)
298 return a.value_ != b.value_;
306 template <
typename Executor>
307 friend ASIO_CONSTEXPR mapping_t query(
312 #if !defined(__clang__) // Clang crashes if noexcept is used here. 313 #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified. 316 #else // defined(ASIO_MSVC) 319 #endif // defined(ASIO_MSVC) 320 #endif // !defined(__clang__) 322 return asio::query(ex, thread_t());
325 template <
typename Executor>
326 friend ASIO_CONSTEXPR mapping_t query(
332 #if !defined(__clang__) // Clang crashes if noexcept is used here. 333 #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified. 336 #else // defined(ASIO_MSVC) 339 #endif // defined(ASIO_MSVC) 340 #endif // !defined(__clang__) 342 return asio::query(ex, new_thread_t());
345 template <
typename Executor>
346 friend ASIO_CONSTEXPR mapping_t query(
353 #if !defined(__clang__) // Clang crashes if noexcept is used here. 354 #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified. 357 #else // defined(ASIO_MSVC) 360 #endif // defined(ASIO_MSVC) 361 #endif // !defined(__clang__) 363 return asio::query(ex, other_t());
366 ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(thread_t,
thread);
367 ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(new_thread_t, new_thread);
368 ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(other_t, other);
370 #if !defined(ASIO_HAS_CONSTEXPR) 371 static const mapping_t instance;
372 #endif // !defined(ASIO_HAS_CONSTEXPR) 378 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 379 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 380 template <
int I>
template <
typename E,
typename T>
382 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 385 #if !defined(ASIO_HAS_CONSTEXPR) 404 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 405 template <
typename T>
406 ASIO_STATIC_CONSTEXPR(
bool,
409 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 419 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 420 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 421 template <
typename T>
422 static ASIO_CONSTEXPR
431 template <
typename T>
432 static ASIO_CONSTEXPR
thread_t static_query(
439 >::type* = 0) ASIO_NOEXCEPT
444 template <
typename E,
typename T = decltype(thread_t::static_query<E>())>
445 static ASIO_CONSTEXPR
const T static_query_v
446 = thread_t::static_query<E>();
447 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 455 friend ASIO_CONSTEXPR
bool operator==(
461 friend ASIO_CONSTEXPR
bool operator!=(
468 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 469 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 470 template <
int I>
template <
typename E,
typename T>
472 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 478 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 479 template <
typename T>
480 ASIO_STATIC_CONSTEXPR(
bool,
483 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 493 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 494 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 495 template <
typename T>
496 static ASIO_CONSTEXPR
505 template <
typename E,
typename T = decltype(new_thread_t::static_query<E>())>
506 static ASIO_CONSTEXPR
const T static_query_v
507 = new_thread_t::static_query<E>();
508 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 516 friend ASIO_CONSTEXPR
bool operator==(
522 friend ASIO_CONSTEXPR
bool operator!=(
529 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 530 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 531 template <
int I>
template <
typename E,
typename T>
533 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 539 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 540 template <
typename T>
541 ASIO_STATIC_CONSTEXPR(
bool,
544 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 554 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 555 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 556 template <
typename T>
557 static ASIO_CONSTEXPR
566 template <
typename E,
typename T = decltype(other_t::static_query<E>())>
567 static ASIO_CONSTEXPR
const T static_query_v
568 = other_t::static_query<E>();
569 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 577 friend ASIO_CONSTEXPR
bool operator==(
583 friend ASIO_CONSTEXPR
bool operator!=(
590 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 591 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 592 template <
int I>
template <
typename E,
typename T>
594 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 602 #if defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) 603 constexpr mapping_t mapping;
604 #else // defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) 605 namespace {
static const mapping_t& mapping = mapping_t::instance; }
610 #if !defined(ASIO_HAS_VARIABLE_TEMPLATES) 612 template <
typename T>
614 : integral_constant<bool,
615 execution::is_executor<T>::value
616 || execution::is_sender<T>::value
617 || execution::is_scheduler<T>::value>
621 template <
typename T>
623 : integral_constant<bool,
624 execution::is_executor<T>::value
625 || execution::is_sender<T>::value
626 || execution::is_scheduler<T>::value>
630 template <
typename T>
632 : integral_constant<bool,
633 execution::is_executor<T>::value
634 || execution::is_sender<T>::value
635 || execution::is_scheduler<T>::value>
639 template <
typename T>
641 : integral_constant<bool,
642 execution::is_executor<T>::value
643 || execution::is_sender<T>::value
644 || execution::is_scheduler<T>::value>
648 #endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES) 652 #if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 654 template <
typename T>
657 can_query<T, execution::mapping_t::thread_t>::value
660 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
661 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
667 template <
typename T>
670 !can_query<T, execution::mapping_t::thread_t>::value
671 && can_query<T, execution::mapping_t::new_thread_t>::value
674 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
675 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
681 template <
typename T>
684 !can_query<T, execution::mapping_t::thread_t>::value
685 && !can_query<T, execution::mapping_t::new_thread_t>::value
686 && can_query<T, execution::mapping_t::other_t>::value
689 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
690 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
696 #endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 698 #if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 699 || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 701 template <
typename T>
704 traits::query_static_constexpr_member<T,
705 execution::mapping_t>::is_valid
708 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
709 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
714 static ASIO_CONSTEXPR result_type value()
721 template <
typename T>
724 !traits::query_static_constexpr_member<T, execution::mapping_t>::is_valid
725 && !traits::query_member<T, execution::mapping_t>::is_valid
726 && traits::static_query<T, execution::mapping_t::thread_t>::is_valid
729 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
730 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
735 static ASIO_CONSTEXPR result_type value()
741 template <
typename T>
744 !traits::query_static_constexpr_member<T, execution::mapping_t>::is_valid
745 && !traits::query_member<T, execution::mapping_t>::is_valid
746 && !traits::static_query<T, execution::mapping_t::thread_t>::is_valid
747 && traits::static_query<T, execution::mapping_t::new_thread_t>::is_valid
750 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
751 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
756 static ASIO_CONSTEXPR result_type value()
762 template <
typename T>
765 !traits::query_static_constexpr_member<T, execution::mapping_t>::is_valid
766 && !traits::query_member<T, execution::mapping_t>::is_valid
767 && !traits::static_query<T, execution::mapping_t::thread_t>::is_valid
768 && !traits::static_query<T, execution::mapping_t::new_thread_t>::is_valid
769 && traits::static_query<T, execution::mapping_t::other_t>::is_valid
772 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
773 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
778 static ASIO_CONSTEXPR result_type value()
784 template <
typename T>
787 traits::query_static_constexpr_member<T,
788 execution::mapping_t::thread_t>::is_valid
791 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
792 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
797 static ASIO_CONSTEXPR result_type value()
804 template <
typename T>
807 !traits::query_static_constexpr_member<T,
808 execution::mapping_t::thread_t>::is_valid
809 && !traits::query_member<T, execution::mapping_t::thread_t>::is_valid
810 && !traits::query_free<T, execution::mapping_t::thread_t>::is_valid
811 && !can_query<T, execution::mapping_t::new_thread_t>::value
812 && !can_query<T, execution::mapping_t::other_t>::value
815 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
816 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
820 static ASIO_CONSTEXPR result_type value()
822 return result_type();
826 template <
typename T>
829 traits::query_static_constexpr_member<T,
830 execution::mapping_t::new_thread_t>::is_valid
833 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
834 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
839 static ASIO_CONSTEXPR result_type value()
846 template <
typename T>
849 traits::query_static_constexpr_member<T,
850 execution::mapping_t::other_t>::is_valid
853 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
854 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
859 static ASIO_CONSTEXPR result_type value()
866 #endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 869 #if !defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT) 871 template <
typename T>
874 static_query<T, execution::mapping_t::thread_t>::is_valid
877 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
883 template <
typename T>
886 static_query<T, execution::mapping_t::new_thread_t>::is_valid
889 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
895 template <
typename T>
898 static_query<T, execution::mapping_t::other_t>::is_valid
901 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
907 #endif // !defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT) 911 #endif // defined(GENERATING_DOCUMENTATION) 915 #include "asio/detail/pop_options.hpp" 917 #endif // ASIO_EXECUTION_MAPPING_HPP Definition: static_require.hpp:37
Definition: any_executor.hpp:249
Definition: mapping.hpp:186
Definition: query.hpp:269
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: mapping.hpp:192
Definition: query.hpp:253
Definition: mapping.hpp:187
A simple abstraction for starting threads.
Definition: thread.hpp:48
Definition: query_free.hpp:35
Definition: query_free.hpp:38
Definition: query_static_constexpr_member.hpp:42
Definition: mapping.hpp:185
Definition: any_executor.hpp:256
Definition: handler_work.hpp:37
Definition: is_applicable_property.hpp:46
Definition: mapping.hpp:301
Definition: any_io_executor.hpp:28
The is_executor trait detects whether a type T satisfies the execution::executor concept.
Definition: executor.hpp:109