11 #ifndef ASIO_EXECUTION_ANY_EXECUTOR_HPP 12 #define ASIO_EXECUTION_ANY_EXECUTOR_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 21 #include "asio/detail/assert.hpp" 22 #include "asio/detail/cstddef.hpp" 23 #include "asio/detail/executor_function.hpp" 24 #include "asio/detail/memory.hpp" 25 #include "asio/detail/non_const_lvalue.hpp" 26 #include "asio/detail/scoped_ptr.hpp" 27 #include "asio/detail/type_traits.hpp" 28 #include "asio/detail/throw_exception.hpp" 29 #include "asio/detail/variadic_templates.hpp" 30 #include "asio/execution/bad_executor.hpp" 31 #include "asio/execution/blocking.hpp" 32 #include "asio/execution/execute.hpp" 33 #include "asio/execution/executor.hpp" 34 #include "asio/prefer.hpp" 35 #include "asio/query.hpp" 36 #include "asio/require.hpp" 38 #include "asio/detail/push_options.hpp" 42 #if defined(GENERATING_DOCUMENTATION) 47 template <
typename... SupportableProperties>
52 any_executor() noexcept;
55 any_executor(nullptr_t) noexcept;
58 any_executor(const any_executor& e) noexcept;
61 any_executor(any_executor&& e) noexcept;
64 template <class... OtherSupportableProperties>
65 any_executor(any_executor<OtherSupportableProperties...> e);
68 template <typename Executor>
69 any_executor(Executor e);
72 any_executor& operator=(const any_executor& e) noexcept;
75 any_executor& operator=(any_executor&& e) noexcept;
78 any_executor& operator=(nullptr_t);
82 template <typename Executor>
83 any_executor& operator=(Executor e);
89 void swap(any_executor& other) noexcept;
100 template <typename Property>
101 any_executor require(Property) const;
112 template <typename Property>
113 any_executor prefer(Property) const;
124 template <typename Property>
125 typename Property::polymorphic_query_result_type query(Property) const;
138 template <typename Function>
139 void execute(Function&& f) const;
147 automatically_determined context() const;
154 explicit operator
bool() const noexcept;
157 const type_info& target_type() const noexcept;
160 template <typename Executor> Executor* target() noexcept;
163 template <typename Executor> const Executor* target() const noexcept;
170 template <typename... SupportableProperties>
171 bool operator==(const any_executor<SupportableProperties...>& a,
172 const any_executor<SupportableProperties...>& b) noexcept;
178 template <typename... SupportableProperties>
179 bool operator==(const any_executor<SupportableProperties...>& a,
186 template <typename... SupportableProperties>
187 bool operator==(nullptr_t,
188 const any_executor<SupportableProperties...>& b) noexcept;
194 template <typename... SupportableProperties>
195 bool operator!=(const any_executor<SupportableProperties...>& a,
196 const any_executor<SupportableProperties...>& b) noexcept;
202 template <typename... SupportableProperties>
203 bool operator!=(const any_executor<SupportableProperties...>& a,
210 template <typename... SupportableProperties>
211 bool operator!=(nullptr_t,
212 const any_executor<SupportableProperties...>& b) noexcept;
216 #else // defined(GENERATING_DOCUMENTATION) 220 #if !defined(ASIO_EXECUTION_ANY_EXECUTOR_FWD_DECL) 221 #define ASIO_EXECUTION_ANY_EXECUTOR_FWD_DECL 223 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 225 template <
typename... SupportableProperties>
228 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 230 template <
typename = void,
typename = void,
typename = void,
231 typename = void,
typename = void,
typename = void,
232 typename = void,
typename = void,
typename =
void>
235 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 237 #endif // !defined(ASIO_EXECUTION_ANY_EXECUTOR_FWD_DECL) 239 template <
typename U>
248 template <
typename T,
typename =
void>
251 template <
typename T>
255 template <
typename T,
typename =
void>
258 template <
typename T>
264 template <
typename T>
267 template <
typename U>
274 template <std::
size_t I,
typename Props>
277 template <std::
size_t I,
typename Prop>
280 template <
typename T>
281 struct is_valid_target : integral_constant<bool,
283 is_requirable<Prop>::value
284 ? can_require<T, Prop>::value
289 is_preferable<Prop>::value
290 ? can_prefer<T, Prop>::value
295 !is_requirable<Prop>::value && !is_preferable<Prop>::value
296 ? can_query<T, Prop>::value
305 ASIO_STATIC_CONSTEXPR(
bool, value =
true);
307 typedef typename Prop::polymorphic_query_result_type query_result_type;
308 ASIO_STATIC_CONSTEXPR(std::size_t, index = I);
313 ASIO_STATIC_CONSTEXPR(
bool, value =
false);
316 template <
typename T>
317 struct find_convertible_property :
319 is_same<T, Prop>::value || is_convertible<T, Prop>::value,
324 template <
typename T>
325 struct find_convertible_requirable_property :
327 is_requirable<Prop>::value
328 && (is_same<T, Prop>::value || is_convertible<T, Prop>::value),
333 template <
typename T>
334 struct find_convertible_preferable_property :
336 is_preferable<Prop>::value
337 && (is_same<T, Prop>::value || is_convertible<T, Prop>::value),
342 struct find_context_as_property :
344 is_context_as<Prop>::value,
350 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 352 template <std::size_t I,
typename Head,
typename... Tail>
355 template <
typename T>
356 struct is_valid_target : integral_constant<bool,
358 supportable_properties<I,
359 void(Head)>::template is_valid_target<T>::value
361 supportable_properties<I + 1,
362 void(Tail...)>::template is_valid_target<T>::value
368 template <
typename T>
369 struct find_convertible_property :
371 is_convertible<T, Head>::value,
372 typename supportable_properties<I, void(Head)>::found,
373 typename supportable_properties<I + 1,
374 void(Tail...)>::template find_convertible_property<T>
377 template <
typename T>
378 struct find_convertible_requirable_property :
380 is_requirable<Head>::value
381 && is_convertible<T, Head>::value,
382 typename supportable_properties<I, void(Head)>::found,
383 typename supportable_properties<I + 1,
384 void(Tail...)>::template find_convertible_requirable_property<T>
387 template <
typename T>
388 struct find_convertible_preferable_property :
390 is_preferable<Head>::value
391 && is_convertible<T, Head>::value,
392 typename supportable_properties<I, void(Head)>::found,
393 typename supportable_properties<I + 1,
394 void(Tail...)>::template find_convertible_preferable_property<T>
397 struct find_context_as_property :
399 is_context_as<Head>::value,
400 typename supportable_properties<I, void(Head)>::found,
401 typename supportable_properties<I + 1,
402 void(Tail...)>::find_context_as_property
406 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 408 #define ASIO_PRIVATE_ANY_EXECUTOR_PROPS_BASE_DEF(n) \ 409 template <std::size_t I, \ 410 typename Head, ASIO_VARIADIC_TPARAMS(n)> \ 411 struct supportable_properties<I, \ 412 void(Head, ASIO_VARIADIC_TARGS(n))> \ 414 template <typename T> \ 415 struct is_valid_target : integral_constant<bool, \ 417 supportable_properties<I, \ 418 void(Head)>::template is_valid_target<T>::value \ 420 supportable_properties<I + 1, \ 421 void(ASIO_VARIADIC_TARGS(n))>::template \ 422 is_valid_target<T>::value \ 428 template <typename T> \ 429 struct find_convertible_property : \ 431 is_convertible<T, Head>::value, \ 432 typename supportable_properties<I, void(Head)>::found, \ 433 typename supportable_properties<I + 1, \ 434 void(ASIO_VARIADIC_TARGS(n))>::template \ 435 find_convertible_property<T> \ 438 template <typename T> \ 439 struct find_convertible_requirable_property : \ 441 is_requirable<Head>::value \ 442 && is_convertible<T, Head>::value, \ 443 typename supportable_properties<I, void(Head)>::found, \ 444 typename supportable_properties<I + 1, \ 445 void(ASIO_VARIADIC_TARGS(n))>::template \ 446 find_convertible_requirable_property<T> \ 449 template <typename T> \ 450 struct find_convertible_preferable_property : \ 452 is_preferable<Head>::value \ 453 && is_convertible<T, Head>::value, \ 454 typename supportable_properties<I, void(Head)>::found, \ 455 typename supportable_properties<I + 1, \ 456 void(ASIO_VARIADIC_TARGS(n))>::template \ 457 find_convertible_preferable_property<T> \ 460 struct find_context_as_property : \ 462 is_context_as<Head>::value, \ 463 typename supportable_properties<I, void(Head)>::found, \ 464 typename supportable_properties<I + 1, void( \ 465 ASIO_VARIADIC_TARGS(n))>::find_context_as_property \ 469 ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_PROPS_BASE_DEF)
470 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROPS_BASE_DEF 472 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 474 template <
typename T,
typename Props>
477 is_executor<T>::value,
478 typename supportable_properties<0, Props>::template is_valid_target<T>,
488 : object_fns_(object_fns_table<void>()),
490 target_fns_(target_fns_table<void>())
494 template <ASIO_EXECUTION_EXECUTOR Executor>
496 : target_fns_(target_fns_table<Executor>(
497 any_executor_base::query_blocking(ex,
499 == execution::blocking.always))
501 any_executor_base::construct_object(ex,
502 integral_constant<
bool,
503 sizeof(Executor) <=
sizeof(object_type)
504 && alignment_of<Executor>::value <= alignment_of<object_type>::value
508 template <ASIO_EXECUTION_EXECUTOR Executor>
510 : object_fns_(object_fns_table<asio::detail::shared_ptr<void> >()),
511 target_fns_(other.target_fns_)
513 asio::detail::shared_ptr<Executor> p =
514 asio::detail::make_shared<Executor>(
515 ASIO_MOVE_CAST(Executor)(other));
516 target_ = p->template target<void>();
517 new (&object_) asio::detail::shared_ptr<void>(
518 ASIO_MOVE_CAST(asio::detail::shared_ptr<Executor>)(p));
522 : object_fns_(other.object_fns_),
523 target_fns_(other.target_fns_)
525 object_fns_->copy(*
this, other);
530 object_fns_->destroy(*
this);
538 object_fns_->destroy(*
this);
539 object_fns_ = other.object_fns_;
540 target_fns_ = other.target_fns_;
541 object_fns_->copy(*
this, other);
548 object_fns_->destroy(*
this);
550 object_fns_ = object_fns_table<void>();
551 target_fns_ = target_fns_table<void>();
555 #if defined(ASIO_HAS_MOVE) 558 : object_fns_(other.object_fns_),
559 target_fns_(other.target_fns_)
561 other.object_fns_ = object_fns_table<void>();
562 other.target_fns_ = target_fns_table<void>();
563 object_fns_->move(*
this, other);
572 object_fns_->destroy(*
this);
573 object_fns_ = other.object_fns_;
574 other.object_fns_ = object_fns_table<void>();
575 target_fns_ = other.target_fns_;
576 other.target_fns_ = target_fns_table<void>();
577 object_fns_->move(*
this, other);
583 #endif // defined(ASIO_HAS_MOVE) 595 template <
typename F>
596 void execute(ASIO_MOVE_ARG(F) f)
const 598 if (target_fns_->blocking_execute != 0)
601 target_fns_->blocking_execute(*
this,
function_view(f2.value));
605 target_fns_->execute(*
this,
606 function(ASIO_MOVE_CAST(F)(f), std::allocator<void>()));
610 template <
typename Executor>
613 return static_cast<Executor*
>(target_);
616 template <
typename Executor>
617 const Executor* target()
const 619 return static_cast<Executor*
>(target_);
622 #if !defined(ASIO_NO_TYPEID) 623 const std::type_info& target_type()
const 624 #else // !defined(ASIO_NO_TYPEID) 625 const void* target_type()
const 626 #endif // !defined(ASIO_NO_TYPEID) 628 return target_fns_->target_type();
635 operator unspecified_bool_type()
const ASIO_NOEXCEPT
637 return target_ ? &any_executor_base::unspecified_bool_true : 0;
640 bool operator!()
const ASIO_NOEXCEPT
648 if (target_ == other.target_)
650 if (target_ && !other.target_)
652 if (!target_ && other.target_)
654 if (target_fns_ != other.target_fns_)
656 return target_fns_->equal(*
this, other);
659 template <
typename Ex>
662 return *
static_cast<Ex*
>(
static_cast<void*
>(&object_));
665 template <
typename Ex>
668 return *
static_cast<const Ex*
>(
static_cast<const void*
>(&object_));
698 template <
typename Obj>
701 is_same<Obj, void>::value
706 &any_executor_base::destroy_void,
707 &any_executor_base::copy_void,
708 &any_executor_base::move_void,
709 &any_executor_base::target_void
716 typedef asio::detail::shared_ptr<void> type;
717 ex.object<type>().~type();
722 typedef asio::detail::shared_ptr<void> type;
723 new (&ex1.object_) type(ex2.object<type>());
724 ex1.target_ = ex2.target_;
729 typedef asio::detail::shared_ptr<void> type;
730 new (&ex1.object_) type(ASIO_MOVE_CAST(type)(ex2.object<type>()));
731 ex1.target_ = ex2.target_;
732 ex2.object<type>().~type();
737 typedef asio::detail::shared_ptr<void> type;
738 return ex.object<type>().
get();
741 template <
typename Obj>
744 is_same<Obj, asio::detail::shared_ptr<void> >::value
749 &any_executor_base::destroy_shared,
750 &any_executor_base::copy_shared,
751 &any_executor_base::move_shared,
752 &any_executor_base::target_shared
757 template <
typename Obj>
760 ex.object<Obj>().~Obj();
763 template <
typename Obj>
766 new (&ex1.object_) Obj(ex2.object<Obj>());
767 ex1.target_ = &ex1.object<Obj>();
770 template <
typename Obj>
773 new (&ex1.object_) Obj(ASIO_MOVE_CAST(Obj)(ex2.object<Obj>()));
774 ex1.target_ = &ex1.object<Obj>();
775 ex2.object<Obj>().~Obj();
778 template <
typename Obj>
781 return &ex.object<Obj>();
784 template <
typename Obj>
787 !is_same<Obj, void>::value
788 && !is_same<Obj, asio::detail::shared_ptr<void> >::value
793 &any_executor_base::destroy_object<Obj>,
794 &any_executor_base::copy_object<Obj>,
795 &any_executor_base::move_object<Obj>,
796 &any_executor_base::target_object<Obj>
806 #if !defined(ASIO_NO_TYPEID) 807 const std::type_info& (*target_type)();
808 #else // !defined(ASIO_NO_TYPEID) 809 const void* (*target_type)();
810 #endif // !defined(ASIO_NO_TYPEID) 812 void (*execute)(
const any_executor_base&, ASIO_MOVE_ARG(
function));
813 void (*blocking_execute)(
const any_executor_base&, function_view);
816 #if !defined(ASIO_NO_TYPEID) 817 static const std::type_info& target_type_void()
821 #else // !defined(ASIO_NO_TYPEID) 822 static const void* target_type_void()
826 #endif // !defined(ASIO_NO_TYPEID) 834 ASIO_MOVE_ARG(
function))
837 asio::detail::throw_exception(ex);
843 asio::detail::throw_exception(ex);
846 template <
typename Ex>
849 is_same<Ex, void>::value
854 &any_executor_base::target_type_void,
855 &any_executor_base::equal_void,
856 &any_executor_base::execute_void,
857 &any_executor_base::blocking_execute_void
862 #if !defined(ASIO_NO_TYPEID) 863 template <
typename Ex>
864 static const std::type_info& target_type_ex()
868 #else // !defined(ASIO_NO_TYPEID) 869 template <
typename Ex>
870 static const void* target_type_ex()
872 static int unique_id;
875 #endif // !defined(ASIO_NO_TYPEID) 877 template <
typename Ex>
881 return *ex1.target<Ex>() == *ex2.target<Ex>();
884 template <
typename Ex>
886 ASIO_MOVE_ARG(
function) f)
888 execution::execute(*ex.target<Ex>(), ASIO_MOVE_CAST(
function)(f));
891 template <
typename Ex>
894 execution::execute(*ex.target<Ex>(), f);
897 template <
typename Ex>
898 static const target_fns* target_fns_table(
bool is_always_blocking,
900 !is_same<Ex, void>::value
905 &any_executor_base::target_type_ex<Ex>,
906 &any_executor_base::equal_ex<Ex>,
907 &any_executor_base::execute_ex<Ex>,
911 static const target_fns fns_with_blocking_execute =
913 &any_executor_base::target_type_ex<Ex>,
914 &any_executor_base::equal_ex<Ex>,
916 &any_executor_base::blocking_execute_ex<Ex>
919 return is_always_blocking ? &fns_with_blocking_execute : &fns_with_execute;
922 #if defined(ASIO_MSVC) 923 # pragma warning (push) 924 # pragma warning (disable:4702) 925 #endif // defined(ASIO_MSVC) 927 static void query_fn_void(
void*,
const void*,
const void*)
930 asio::detail::throw_exception(ex);
933 template <
typename Ex,
class Prop>
934 static void query_fn_non_void(
void*,
const void* ex,
const void*
prop,
937 && is_same<typename Prop::polymorphic_query_result_type, void>::value
940 asio::query(*static_cast<const Ex*>(ex),
941 *static_cast<const Prop*>(prop));
944 template <
typename Ex,
class Prop>
945 static void query_fn_non_void(
void*,
const void*,
const void*,
948 && is_same<typename Prop::polymorphic_query_result_type, void>::value
953 template <
typename Ex,
class Prop>
954 static void query_fn_non_void(
void* result,
const void* ex,
const void* prop,
957 && !is_same<typename Prop::polymorphic_query_result_type, void>::value
958 && is_reference<typename Prop::polymorphic_query_result_type>::value
961 *
static_cast<typename remove_reference<
962 typename Prop::polymorphic_query_result_type
>::type**>(result)
963 = &static_cast<typename Prop::polymorphic_query_result_type>(
964 asio::query(*static_cast<const Ex*>(ex),
965 *static_cast<const Prop*>(prop)));
968 template <
typename Ex,
class Prop>
969 static void query_fn_non_void(
void*,
const void*,
const void*,
972 && !is_same<typename Prop::polymorphic_query_result_type, void>::value
973 && is_reference<typename Prop::polymorphic_query_result_type>::value
979 template <
typename Ex,
class Prop>
980 static void query_fn_non_void(
void* result,
const void* ex,
const void* prop,
983 && !is_same<typename Prop::polymorphic_query_result_type, void>::value
984 && is_scalar<typename Prop::polymorphic_query_result_type>::value
987 *
static_cast<typename Prop::polymorphic_query_result_type*
>(result)
988 = static_cast<typename Prop::polymorphic_query_result_type>(
989 asio::query(*static_cast<const Ex*>(ex),
990 *static_cast<const Prop*>(prop)));
993 template <
typename Ex,
class Prop>
994 static void query_fn_non_void(
void* result,
const void*,
const void*,
997 && !is_same<typename Prop::polymorphic_query_result_type, void>::value
998 && is_scalar<typename Prop::polymorphic_query_result_type>::value
1001 *
static_cast<typename Prop::polymorphic_query_result_type*
>(result)
1002 =
typename Prop::polymorphic_query_result_type();
1005 template <
typename Ex,
class Prop>
1006 static void query_fn_non_void(
void* result,
const void* ex,
const void* prop,
1009 && !is_same<typename Prop::polymorphic_query_result_type, void>::value
1010 && !is_reference<typename Prop::polymorphic_query_result_type>::value
1011 && !is_scalar<typename Prop::polymorphic_query_result_type>::value
1014 *
static_cast<typename Prop::polymorphic_query_result_type**
>(result)
1015 =
new typename Prop::polymorphic_query_result_type(
1016 asio::query(*static_cast<const Ex*>(ex),
1017 *static_cast<const Prop*>(prop)));
1020 template <
typename Ex,
class Prop>
1021 static void query_fn_non_void(
void* result,
const void*,
const void*, ...)
1023 *
static_cast<typename Prop::polymorphic_query_result_type**
>(result)
1024 =
new typename Prop::polymorphic_query_result_type();
1027 template <
typename Ex,
class Prop>
1028 static void query_fn_impl(
void* result,
const void* ex,
const void* prop,
1030 is_same<Ex, void>::value
1033 query_fn_void(result, ex, prop);
1036 template <
typename Ex,
class Prop>
1037 static void query_fn_impl(
void* result,
const void* ex,
const void* prop,
1039 !is_same<Ex, void>::value
1042 query_fn_non_void<Ex, Prop>(result, ex, prop, 0);
1045 template <
typename Ex,
class Prop>
1046 static void query_fn(
void* result,
const void* ex,
const void* prop)
1048 query_fn_impl<Ex, Prop>(result, ex, prop, 0);
1051 template <
typename Poly,
typename Ex,
class Prop>
1052 static Poly require_fn_impl(
const void*,
const void*,
1054 is_same<Ex, void>::value
1058 asio::detail::throw_exception(ex);
1062 template <
typename Poly,
typename Ex,
class Prop>
1063 static Poly require_fn_impl(
const void* ex,
const void* prop,
1065 !is_same<Ex, void>::value && Prop::is_requirable
1068 return asio::require(*static_cast<const Ex*>(ex),
1069 *static_cast<const Prop*>(prop));
1072 template <
typename Poly,
typename Ex,
class Prop>
1073 static Poly require_fn_impl(
const void*,
const void*, ...)
1078 template <
typename Poly,
typename Ex,
class Prop>
1079 static Poly require_fn(
const void* ex,
const void* prop)
1081 return require_fn_impl<Poly, Ex, Prop>(ex, prop, 0);
1084 template <
typename Poly,
typename Ex,
class Prop>
1085 static Poly prefer_fn_impl(
const void*,
const void*,
1087 is_same<Ex, void>::value
1091 asio::detail::throw_exception(ex);
1095 template <
typename Poly,
typename Ex,
class Prop>
1096 static Poly prefer_fn_impl(
const void* ex,
const void* prop,
1098 !is_same<Ex, void>::value && Prop::is_preferable
1101 return asio::prefer(*static_cast<const Ex*>(ex),
1102 *static_cast<const Prop*>(prop));
1105 template <
typename Poly,
typename Ex,
class Prop>
1106 static Poly prefer_fn_impl(
const void*,
const void*, ...)
1111 template <
typename Poly,
typename Ex,
class Prop>
1112 static Poly prefer_fn(
const void* ex,
const void* prop)
1114 return prefer_fn_impl<Poly, Ex, Prop>(ex, prop, 0);
1117 template <
typename Poly>
1120 void (*query)(
void*,
const void*,
const void*);
1121 Poly (*require)(
const void*,
const void*);
1122 Poly (*prefer)(
const void*,
const void*);
1125 #if defined(ASIO_MSVC) 1126 # pragma warning (pop) 1127 #endif // defined(ASIO_MSVC) 1130 template <
typename Executor>
1133 return asio::query(ex, execution::blocking);
1136 template <
typename Executor>
1142 template <
typename Executor>
1143 void construct_object(Executor& ex, true_type)
1145 object_fns_ = object_fns_table<Executor>();
1146 target_ =
new (&object_) Executor(ASIO_MOVE_CAST(Executor)(ex));
1149 template <
typename Executor>
1150 void construct_object(Executor& ex, false_type)
1152 object_fns_ = object_fns_table<asio::detail::shared_ptr<void> >();
1153 asio::detail::shared_ptr<Executor> p =
1154 asio::detail::make_shared<Executor>(
1155 ASIO_MOVE_CAST(Executor)(ex));
1157 new (&object_) asio::detail::shared_ptr<void>(
1158 ASIO_MOVE_CAST(asio::detail::shared_ptr<Executor>)(p));
1164 typedef aligned_storage<
1165 sizeof(asio::detail::shared_ptr<void>),
1166 alignment_of<asio::detail::shared_ptr<void> >::value
1167 >::type object_type;
1169 object_type object_;
1175 template <
typename Derived,
typename Property,
typename =
void>
1180 #if !defined(ASIO_NO_TS_EXECUTORS) 1182 template <
typename Derived,
typename Property>
1184 typename
enable_if<Property::value>::type>
1186 typename Property::query_result_type context()
const 1188 return static_cast<const Derived*
>(
this)->query(
typename Property::type());
1192 #endif // !defined(ASIO_NO_TS_EXECUTORS) 1210 template <
typename Executor>
1214 !is_same<Executor, any_executor>::value
1215 && !is_base_of<detail::any_executor_base, Executor>::value,
1221 ASIO_MOVE_CAST(Executor)(ex), false_type())
1225 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 1227 template <
typename... OtherSupportableProperties>
1230 static_cast<const detail::any_executor_base&>(other))
1234 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 1236 template <
typename U0,
typename U1,
typename U2,
typename U3,
1237 typename U4,
typename U5,
typename U6,
typename U7>
1240 static_cast<const detail::any_executor_base&>(other))
1244 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 1246 any_executor(
const any_executor& other) ASIO_NOEXCEPT
1248 static_cast<const detail::any_executor_base&>(other))
1252 any_executor& operator=(
const any_executor& other) ASIO_NOEXCEPT
1256 detail::any_executor_base::operator=(
1257 static_cast<const detail::any_executor_base&>(other));
1262 any_executor& operator=(nullptr_t p) ASIO_NOEXCEPT
1264 detail::any_executor_base::operator=(p);
1268 #if defined(ASIO_HAS_MOVE) 1270 any_executor(any_executor&& other) ASIO_NOEXCEPT
1272 static_cast<any_executor_base&&>(
1273 static_cast<any_executor_base&>(other)))
1277 any_executor& operator=(any_executor&& other) ASIO_NOEXCEPT
1281 detail::any_executor_base::operator=(
1282 static_cast<detail::any_executor_base&&>(
1283 static_cast<detail::any_executor_base&>(other)));
1288 #endif // defined(ASIO_HAS_MOVE) 1290 void swap(any_executor& other) ASIO_NOEXCEPT
1292 detail::any_executor_base::swap(
1293 static_cast<detail::any_executor_base&>(other));
1296 using detail::any_executor_base::execute;
1297 using detail::any_executor_base::target;
1298 using detail::any_executor_base::target_type;
1299 using detail::any_executor_base::operator unspecified_bool_type;
1300 using detail::any_executor_base::operator!;
1302 bool equality_helper(
const any_executor& other)
const ASIO_NOEXCEPT
1304 return any_executor_base::equality_helper(other);
1307 template <
typename AnyExecutor1,
typename AnyExecutor2>
1309 is_same<AnyExecutor1, any_executor>::value
1310 || is_same<AnyExecutor2, any_executor>::value,
1312 >::type operator==(
const AnyExecutor1& a,
1313 const AnyExecutor2& b) ASIO_NOEXCEPT
1315 return static_cast<const any_executor&
>(a).equality_helper(b);
1318 template <
typename AnyExecutor>
1320 is_same<AnyExecutor, any_executor>::value,
1322 >::type operator==(
const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
1327 template <
typename AnyExecutor>
1329 is_same<AnyExecutor, any_executor>::value,
1331 >::type operator==(nullptr_t,
const AnyExecutor& b) ASIO_NOEXCEPT
1336 template <
typename AnyExecutor1,
typename AnyExecutor2>
1338 is_same<AnyExecutor1, any_executor>::value
1339 || is_same<AnyExecutor2, any_executor>::value,
1341 >::type operator!=(
const AnyExecutor1& a,
1342 const AnyExecutor2& b) ASIO_NOEXCEPT
1344 return !
static_cast<const any_executor&
>(a).equality_helper(b);
1347 template <
typename AnyExecutor>
1349 is_same<AnyExecutor, any_executor>::value,
1351 >::type operator!=(
const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
1356 template <
typename AnyExecutor>
1358 is_same<AnyExecutor, any_executor>::value,
1360 >::type operator!=(nullptr_t,
const AnyExecutor& b) ASIO_NOEXCEPT
1371 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 1373 template <
typename... SupportableProperties>
1377 any_executor<SupportableProperties...>,
1378 typename detail::supportable_properties<
1379 0, void(SupportableProperties...)>::find_context_as_property>
1384 prop_fns_(prop_fns_table<void>())
1390 prop_fns_(prop_fns_table<void>())
1394 template <
typename Executor>
1398 !is_same<Executor, any_executor>::value
1399 && !is_base_of<detail::any_executor_base, Executor>::value,
1401 Executor,
void(SupportableProperties...)>,
1406 ASIO_MOVE_CAST(Executor)(ex), false_type()),
1407 prop_fns_(prop_fns_table<Executor>())
1411 template <
typename... OtherSupportableProperties>
1420 0,
void(SupportableProperties...)>::
template is_valid_target<
1431 any_executor(
const any_executor& other) ASIO_NOEXCEPT
1433 static_cast<const detail::any_executor_base&>(other)),
1434 prop_fns_(other.prop_fns_)
1438 any_executor& operator=(
const any_executor& other) ASIO_NOEXCEPT
1442 prop_fns_ = other.prop_fns_;
1443 detail::any_executor_base::operator=(
1444 static_cast<const detail::any_executor_base&>(other));
1449 any_executor& operator=(nullptr_t p) ASIO_NOEXCEPT
1451 prop_fns_ = prop_fns_table<void>();
1452 detail::any_executor_base::operator=(p);
1456 #if defined(ASIO_HAS_MOVE) 1458 any_executor(any_executor&& other) ASIO_NOEXCEPT
1460 static_cast<any_executor_base&&>(
1461 static_cast<any_executor_base&>(other))),
1462 prop_fns_(other.prop_fns_)
1464 other.prop_fns_ = prop_fns_table<void>();
1467 any_executor& operator=(any_executor&& other) ASIO_NOEXCEPT
1471 prop_fns_ = other.prop_fns_;
1472 detail::any_executor_base::operator=(
1473 static_cast<detail::any_executor_base&&>(
1474 static_cast<detail::any_executor_base&>(other)));
1479 #endif // defined(ASIO_HAS_MOVE) 1481 void swap(any_executor& other) ASIO_NOEXCEPT
1485 detail::any_executor_base::swap(
1486 static_cast<detail::any_executor_base&>(other));
1488 other.prop_fns_ = prop_fns_;
1489 prop_fns_ = tmp_prop_fns;
1493 using detail::any_executor_base::execute;
1494 using detail::any_executor_base::target;
1495 using detail::any_executor_base::target_type;
1496 using detail::any_executor_base::operator unspecified_bool_type;
1497 using detail::any_executor_base::operator!;
1499 bool equality_helper(
const any_executor& other)
const ASIO_NOEXCEPT
1501 return any_executor_base::equality_helper(other);
1504 template <
typename AnyExecutor1,
typename AnyExecutor2>
1506 is_same<AnyExecutor1, any_executor>::value
1507 || is_same<AnyExecutor2, any_executor>::value,
1509 >::type operator==(
const AnyExecutor1& a,
1510 const AnyExecutor2& b) ASIO_NOEXCEPT
1512 return static_cast<const any_executor&
>(a).equality_helper(b);
1515 template <
typename AnyExecutor>
1517 is_same<AnyExecutor, any_executor>::value,
1519 >::type operator==(
const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
1524 template <
typename AnyExecutor>
1526 is_same<AnyExecutor, any_executor>::value,
1528 >::type operator==(nullptr_t,
const AnyExecutor& b) ASIO_NOEXCEPT
1533 template <
typename AnyExecutor1,
typename AnyExecutor2>
1535 is_same<AnyExecutor1, any_executor>::value
1536 || is_same<AnyExecutor2, any_executor>::value,
1538 >::type operator!=(
const AnyExecutor1& a,
1539 const AnyExecutor2& b) ASIO_NOEXCEPT
1541 return !
static_cast<const any_executor&
>(a).equality_helper(b);
1544 template <
typename AnyExecutor>
1546 is_same<AnyExecutor, any_executor>::value,
1548 >::type operator!=(
const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
1553 template <
typename AnyExecutor>
1555 is_same<AnyExecutor, any_executor>::value,
1557 >::type operator!=(nullptr_t,
const AnyExecutor& b) ASIO_NOEXCEPT
1562 template <
typename T>
1563 struct find_convertible_property :
1565 0, void(SupportableProperties...)>::template
1566 find_convertible_property<T> {};
1568 template <
typename Property>
1569 void query(
const Property& p,
1572 typename find_convertible_property<Property>::query_result_type,
1577 typedef find_convertible_property<Property> found;
1578 prop_fns_[found::index].query(0, object_fns_->target(*
this),
1579 &
static_cast<const typename found::type&
>(p));
1582 template <
typename Property>
1583 typename find_convertible_property<Property>::query_result_type
1584 query(
const Property& p,
1587 typename find_convertible_property<Property>::query_result_type,
1592 typename find_convertible_property<Property>::query_result_type
1596 typedef find_convertible_property<Property> found;
1597 typename remove_reference<
1598 typename found::query_result_type>::type* result = 0;
1599 prop_fns_[found::index].query(&result, object_fns_->target(*
this),
1600 &
static_cast<const typename found::type&
>(p));
1604 template <
typename Property>
1605 typename find_convertible_property<Property>::query_result_type
1606 query(
const Property& p,
1609 typename find_convertible_property<Property>::query_result_type,
1614 typename find_convertible_property<Property>::query_result_type
1618 typedef find_convertible_property<Property> found;
1619 typename found::query_result_type result;
1620 prop_fns_[found::index].query(&result, object_fns_->target(*
this),
1621 &
static_cast<const typename found::type&
>(p));
1625 template <
typename Property>
1626 typename find_convertible_property<Property>::query_result_type
1627 query(
const Property& p,
1630 typename find_convertible_property<Property>::query_result_type,
1635 typename find_convertible_property<Property>::query_result_type
1639 typename find_convertible_property<Property>::query_result_type
1643 typedef find_convertible_property<Property> found;
1644 typename found::query_result_type* result;
1645 prop_fns_[found::index].query(&result, object_fns_->target(*
this),
1646 &
static_cast<const typename found::type&
>(p));
1648 typename found::query_result_type>(result);
1651 template <
typename T>
1652 struct find_convertible_requirable_property :
1654 0, void(SupportableProperties...)>::template
1655 find_convertible_requirable_property<T> {};
1657 template <
typename Property>
1658 any_executor require(
const Property& p,
1660 find_convertible_requirable_property<Property>::value
1663 typedef find_convertible_requirable_property<Property> found;
1664 return prop_fns_[found::index].require(object_fns_->target(*
this),
1665 &
static_cast<const typename found::type&
>(p));
1668 template <
typename T>
1669 struct find_convertible_preferable_property :
1671 0, void(SupportableProperties...)>::template
1672 find_convertible_preferable_property<T> {};
1674 template <
typename Property>
1675 any_executor prefer(
const Property& p,
1677 find_convertible_preferable_property<Property>::value
1680 typedef find_convertible_preferable_property<Property> found;
1681 return prop_fns_[found::index].prefer(object_fns_->target(*
this),
1682 &
static_cast<const typename found::type&
>(p));
1686 template <
typename Ex>
1692 &detail::any_executor_base::query_fn<
1693 Ex, SupportableProperties>,
1694 &detail::any_executor_base::require_fn<
1695 any_executor, Ex, SupportableProperties>,
1696 &detail::any_executor_base::prefer_fn<
1697 any_executor, Ex, SupportableProperties>
1706 template <
typename... SupportableProperties>
1713 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 1715 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS(n) \ 1716 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_##n 1718 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_1 \ 1720 &detail::any_executor_base::query_fn<Ex, T1>, \ 1721 &detail::any_executor_base::require_fn<any_executor, Ex, T1>, \ 1722 &detail::any_executor_base::prefer_fn<any_executor, Ex, T1> \ 1724 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_2 \ 1725 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_1, \ 1727 &detail::any_executor_base::query_fn<Ex, T2>, \ 1728 &detail::any_executor_base::require_fn<any_executor, Ex, T2>, \ 1729 &detail::any_executor_base::prefer_fn<any_executor, Ex, T2> \ 1731 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_3 \ 1732 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_2, \ 1734 &detail::any_executor_base::query_fn<Ex, T3>, \ 1735 &detail::any_executor_base::require_fn<any_executor, Ex, T3>, \ 1736 &detail::any_executor_base::prefer_fn<any_executor, Ex, T3> \ 1738 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_4 \ 1739 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_3, \ 1741 &detail::any_executor_base::query_fn<Ex, T4>, \ 1742 &detail::any_executor_base::require_fn<any_executor, Ex, T4>, \ 1743 &detail::any_executor_base::prefer_fn<any_executor, Ex, T4> \ 1745 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_5 \ 1746 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_4, \ 1748 &detail::any_executor_base::query_fn<Ex, T5>, \ 1749 &detail::any_executor_base::require_fn<any_executor, Ex, T5>, \ 1750 &detail::any_executor_base::prefer_fn<any_executor, Ex, T5> \ 1752 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_6 \ 1753 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_5, \ 1755 &detail::any_executor_base::query_fn<Ex, T6>, \ 1756 &detail::any_executor_base::require_fn<any_executor, Ex, T6>, \ 1757 &detail::any_executor_base::prefer_fn<any_executor, Ex, T6> \ 1759 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_7 \ 1760 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_6, \ 1762 &detail::any_executor_base::query_fn<Ex, T7>, \ 1763 &detail::any_executor_base::require_fn<any_executor, Ex, T7>, \ 1764 &detail::any_executor_base::prefer_fn<any_executor, Ex, T7> \ 1766 #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_8 \ 1767 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_7, \ 1769 &detail::any_executor_base::query_fn<Ex, T8>, \ 1770 &detail::any_executor_base::require_fn<any_executor, Ex, T8>, \ 1771 &detail::any_executor_base::prefer_fn<any_executor, Ex, T8> \ 1774 #if defined(ASIO_HAS_MOVE) 1776 # define ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS \ 1777 any_executor(any_executor&& other) ASIO_NOEXCEPT \ 1778 : detail::any_executor_base( \ 1779 static_cast<any_executor_base&&>( \ 1780 static_cast<any_executor_base&>(other))), \ 1781 prop_fns_(other.prop_fns_) \ 1783 other.prop_fns_ = prop_fns_table<void>(); \ 1786 any_executor& operator=(any_executor&& other) ASIO_NOEXCEPT \ 1788 if (this != &other) \ 1790 prop_fns_ = other.prop_fns_; \ 1791 detail::any_executor_base::operator=( \ 1792 static_cast<detail::any_executor_base&&>( \ 1793 static_cast<detail::any_executor_base&>(other))); \ 1798 #else // defined(ASIO_HAS_MOVE) 1800 # define ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS 1802 #endif // defined(ASIO_HAS_MOVE) 1804 #define ASIO_PRIVATE_ANY_EXECUTOR_DEF(n) \ 1805 template <ASIO_VARIADIC_TPARAMS(n)> \ 1806 class any_executor<ASIO_VARIADIC_TARGS(n)> : \ 1807 public detail::any_executor_base, \ 1808 public detail::any_executor_context< \ 1809 any_executor<ASIO_VARIADIC_TARGS(n)>, \ 1810 typename detail::supportable_properties< \ 1811 0, void(ASIO_VARIADIC_TARGS(n))>::find_context_as_property> \ 1814 any_executor() ASIO_NOEXCEPT \ 1815 : detail::any_executor_base(), \ 1816 prop_fns_(prop_fns_table<void>()) \ 1820 any_executor(nullptr_t) ASIO_NOEXCEPT \ 1821 : detail::any_executor_base(), \ 1822 prop_fns_(prop_fns_table<void>()) \ 1826 template <ASIO_EXECUTION_EXECUTOR Executor> \ 1827 any_executor(Executor ex, \ 1828 typename enable_if< \ 1830 !is_same<Executor, any_executor>::value \ 1831 && !is_base_of<detail::any_executor_base, Executor>::value, \ 1832 detail::is_valid_target_executor< \ 1833 Executor, void(ASIO_VARIADIC_TARGS(n))>, \ 1837 : detail::any_executor_base(ASIO_MOVE_CAST( \ 1838 Executor)(ex), false_type()), \ 1839 prop_fns_(prop_fns_table<Executor>()) \ 1843 any_executor(const any_executor& other) ASIO_NOEXCEPT \ 1844 : detail::any_executor_base( \ 1845 static_cast<const detail::any_executor_base&>(other)), \ 1846 prop_fns_(other.prop_fns_) \ 1850 any_executor(any_executor<> other) \ 1851 : detail::any_executor_base(ASIO_MOVE_CAST( \ 1852 any_executor<>)(other), true_type()), \ 1853 prop_fns_(prop_fns_table<any_executor<> >()) \ 1857 template <typename OtherAnyExecutor> \ 1858 any_executor(OtherAnyExecutor other, \ 1859 typename enable_if< \ 1861 !is_same<OtherAnyExecutor, any_executor>::value \ 1862 && is_base_of<detail::any_executor_base, \ 1863 OtherAnyExecutor>::value, \ 1864 typename detail::supportable_properties< \ 1865 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 1866 is_valid_target<OtherAnyExecutor>, \ 1870 : detail::any_executor_base(ASIO_MOVE_CAST( \ 1871 OtherAnyExecutor)(other), true_type()), \ 1872 prop_fns_(prop_fns_table<OtherAnyExecutor>()) \ 1876 any_executor& operator=(const any_executor& other) ASIO_NOEXCEPT \ 1878 if (this != &other) \ 1880 prop_fns_ = other.prop_fns_; \ 1881 detail::any_executor_base::operator=( \ 1882 static_cast<const detail::any_executor_base&>(other)); \ 1887 any_executor& operator=(nullptr_t p) ASIO_NOEXCEPT \ 1889 prop_fns_ = prop_fns_table<void>(); \ 1890 detail::any_executor_base::operator=(p); \ 1894 ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS \ 1896 void swap(any_executor& other) ASIO_NOEXCEPT \ 1898 if (this != &other) \ 1900 detail::any_executor_base::swap( \ 1901 static_cast<detail::any_executor_base&>(other)); \ 1902 const prop_fns<any_executor>* tmp_prop_fns = other.prop_fns_; \ 1903 other.prop_fns_ = prop_fns_; \ 1904 prop_fns_ = tmp_prop_fns; \ 1908 using detail::any_executor_base::execute; \ 1909 using detail::any_executor_base::target; \ 1910 using detail::any_executor_base::target_type; \ 1911 using detail::any_executor_base::operator unspecified_bool_type; \ 1912 using detail::any_executor_base::operator!; \ 1914 bool equality_helper(const any_executor& other) const ASIO_NOEXCEPT \ 1916 return any_executor_base::equality_helper(other); \ 1919 template <typename AnyExecutor1, typename AnyExecutor2> \ 1920 friend typename enable_if< \ 1921 is_same<AnyExecutor1, any_executor>::value \ 1922 || is_same<AnyExecutor2, any_executor>::value, \ 1924 >::type operator==(const AnyExecutor1& a, \ 1925 const AnyExecutor2& b) ASIO_NOEXCEPT \ 1927 return static_cast<const any_executor&>(a).equality_helper(b); \ 1930 template <typename AnyExecutor> \ 1931 friend typename enable_if< \ 1932 is_same<AnyExecutor, any_executor>::value, \ 1934 >::type operator==(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT \ 1939 template <typename AnyExecutor> \ 1940 friend typename enable_if< \ 1941 is_same<AnyExecutor, any_executor>::value, \ 1943 >::type operator==(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT \ 1948 template <typename AnyExecutor1, typename AnyExecutor2> \ 1949 friend typename enable_if< \ 1950 is_same<AnyExecutor1, any_executor>::value \ 1951 || is_same<AnyExecutor2, any_executor>::value, \ 1953 >::type operator!=(const AnyExecutor1& a, \ 1954 const AnyExecutor2& b) ASIO_NOEXCEPT \ 1956 return !static_cast<const any_executor&>(a).equality_helper(b); \ 1959 template <typename AnyExecutor> \ 1960 friend typename enable_if< \ 1961 is_same<AnyExecutor, any_executor>::value, \ 1963 >::type operator!=(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT \ 1968 template <typename AnyExecutor> \ 1969 friend typename enable_if< \ 1970 is_same<AnyExecutor, any_executor>::value, \ 1972 >::type operator!=(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT \ 1977 template <typename T> \ 1978 struct find_convertible_property : \ 1979 detail::supportable_properties< \ 1980 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 1981 find_convertible_property<T> {}; \ 1983 template <typename Property> \ 1984 void query(const Property& p, \ 1985 typename enable_if< \ 1987 typename find_convertible_property<Property>::query_result_type, \ 1990 >::type* = 0) const \ 1992 typedef find_convertible_property<Property> found; \ 1993 prop_fns_[found::index].query(0, object_fns_->target(*this), \ 1994 &static_cast<const typename found::type&>(p)); \ 1997 template <typename Property> \ 1998 typename find_convertible_property<Property>::query_result_type \ 1999 query(const Property& p, \ 2000 typename enable_if< \ 2002 typename find_convertible_property<Property>::query_result_type, \ 2007 typename find_convertible_property<Property>::query_result_type \ 2009 >::type* = 0) const \ 2011 typedef find_convertible_property<Property> found; \ 2012 typename remove_reference< \ 2013 typename found::query_result_type>::type* result; \ 2014 prop_fns_[found::index].query(&result, object_fns_->target(*this), \ 2015 &static_cast<const typename found::type&>(p)); \ 2019 template <typename Property> \ 2020 typename find_convertible_property<Property>::query_result_type \ 2021 query(const Property& p, \ 2022 typename enable_if< \ 2024 typename find_convertible_property<Property>::query_result_type, \ 2029 typename find_convertible_property<Property>::query_result_type \ 2031 >::type* = 0) const \ 2033 typedef find_convertible_property<Property> found; \ 2034 typename found::query_result_type result; \ 2035 prop_fns_[found::index].query(&result, object_fns_->target(*this), \ 2036 &static_cast<const typename found::type&>(p)); \ 2040 template <typename Property> \ 2041 typename find_convertible_property<Property>::query_result_type \ 2042 query(const Property& p, \ 2043 typename enable_if< \ 2045 typename find_convertible_property<Property>::query_result_type, \ 2050 typename find_convertible_property<Property>::query_result_type \ 2054 typename find_convertible_property<Property>::query_result_type \ 2056 >::type* = 0) const \ 2058 typedef find_convertible_property<Property> found; \ 2059 typename found::query_result_type* result; \ 2060 prop_fns_[found::index].query(&result, object_fns_->target(*this), \ 2061 &static_cast<const typename found::type&>(p)); \ 2062 return *asio::detail::scoped_ptr< \ 2063 typename found::query_result_type>(result); \ 2066 template <typename T> \ 2067 struct find_convertible_requirable_property : \ 2068 detail::supportable_properties< \ 2069 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 2070 find_convertible_requirable_property<T> {}; \ 2072 template <typename Property> \ 2073 any_executor require(const Property& p, \ 2074 typename enable_if< \ 2075 find_convertible_requirable_property<Property>::value \ 2076 >::type* = 0) const \ 2078 typedef find_convertible_requirable_property<Property> found; \ 2079 return prop_fns_[found::index].require(object_fns_->target(*this), \ 2080 &static_cast<const typename found::type&>(p)); \ 2083 template <typename T> \ 2084 struct find_convertible_preferable_property : \ 2085 detail::supportable_properties< \ 2086 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 2087 find_convertible_preferable_property<T> {}; \ 2089 template <typename Property> \ 2090 any_executor prefer(const Property& p, \ 2091 typename enable_if< \ 2092 find_convertible_preferable_property<Property>::value \ 2093 >::type* = 0) const \ 2095 typedef find_convertible_preferable_property<Property> found; \ 2096 return prop_fns_[found::index].prefer(object_fns_->target(*this), \ 2097 &static_cast<const typename found::type&>(p)); \ 2100 template <typename Ex> \ 2101 static const prop_fns<any_executor>* prop_fns_table() \ 2103 static const prop_fns<any_executor> fns[] = \ 2105 ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS(n) \ 2110 const prop_fns<any_executor>* prop_fns_; \ 2111 typedef detail::supportable_properties<0, \ 2112 void(ASIO_VARIADIC_TARGS(n))> supportable_properties_type; \ 2115 template <ASIO_VARIADIC_TPARAMS(n)> \ 2116 inline void swap(any_executor<ASIO_VARIADIC_TARGS(n)>& a, \ 2117 any_executor<ASIO_VARIADIC_TARGS(n)>& b) ASIO_NOEXCEPT \ 2122 ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_DEF)
2123 #undef ASIO_PRIVATE_ANY_EXECUTOR_DEF 2124 #undef ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS 2125 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS 2126 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_1 2127 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_2 2128 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_3 2129 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_4 2130 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_5 2131 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_6 2132 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_7 2133 #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_8 2135 #endif // if defined(ASIO_HAS_VARIADIC_TEMPLATES) 2140 #if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) 2141 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 2143 template <
typename... SupportableProperties>
2144 struct equality_comparable<execution::
any_executor<SupportableProperties...> >
2146 static const bool is_valid =
true;
2147 static const bool is_noexcept =
true;
2150 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2155 static const bool is_valid =
true;
2156 static const bool is_noexcept =
true;
2159 #define ASIO_PRIVATE_ANY_EXECUTOR_EQUALITY_COMPARABLE_DEF(n) \ 2160 template <ASIO_VARIADIC_TPARAMS(n)> \ 2161 struct equality_comparable< \ 2162 execution::any_executor<ASIO_VARIADIC_TARGS(n)> > \ 2164 static const bool is_valid = true; \ 2165 static const bool is_noexcept = true; \ 2168 ASIO_VARIADIC_GENERATE(
2169 ASIO_PRIVATE_ANY_EXECUTOR_EQUALITY_COMPARABLE_DEF)
2170 #undef ASIO_PRIVATE_ANY_EXECUTOR_EQUALITY_COMPARABLE_DEF 2172 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2173 #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) 2175 #if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) 2176 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 2178 template <
typename F,
typename... SupportableProperties>
2179 struct execute_member<execution::any_executor<SupportableProperties...>, F>
2181 static const bool is_valid =
true;
2182 static const bool is_noexcept =
false;
2183 typedef void result_type;
2186 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2188 template <
typename F>
2191 static const bool is_valid =
true;
2192 static const bool is_noexcept =
false;
2193 typedef void result_type;
2196 #define ASIO_PRIVATE_ANY_EXECUTOR_EXECUTE_MEMBER_DEF(n) \ 2197 template <typename F, ASIO_VARIADIC_TPARAMS(n)> \ 2198 struct execute_member< \ 2199 execution::any_executor<ASIO_VARIADIC_TARGS(n)>, F> \ 2201 static const bool is_valid = true; \ 2202 static const bool is_noexcept = false; \ 2203 typedef void result_type; \ 2206 ASIO_VARIADIC_GENERATE(
2207 ASIO_PRIVATE_ANY_EXECUTOR_EXECUTE_MEMBER_DEF)
2208 #undef ASIO_PRIVATE_ANY_EXECUTOR_EXECUTE_MEMBER_DEF 2210 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2211 #endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) 2213 #if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) 2214 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 2216 template <
typename Prop,
typename... SupportableProperties>
2218 execution::any_executor<SupportableProperties...>, Prop,
2220 execution::detail::supportable_properties<
2221 0, void(SupportableProperties...)>::template
2222 find_convertible_property<Prop>::value
2225 static const bool is_valid =
true;
2226 static const bool is_noexcept =
false;
2228 0, void(SupportableProperties...)>::template
2229 find_convertible_property<Prop>::query_result_type result_type;
2232 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2234 #define ASIO_PRIVATE_ANY_EXECUTOR_QUERY_MEMBER_DEF(n) \ 2235 template <typename Prop, ASIO_VARIADIC_TPARAMS(n)> \ 2236 struct query_member< \ 2237 execution::any_executor<ASIO_VARIADIC_TARGS(n)>, Prop, \ 2238 typename enable_if< \ 2239 execution::detail::supportable_properties< \ 2240 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 2241 find_convertible_property<Prop>::value \ 2244 static const bool is_valid = true; \ 2245 static const bool is_noexcept = false; \ 2246 typedef typename execution::detail::supportable_properties< \ 2247 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 2248 find_convertible_property<Prop>::query_result_type result_type; \ 2251 ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_QUERY_MEMBER_DEF)
2252 #undef ASIO_PRIVATE_ANY_EXECUTOR_QUERY_MEMBER_DEF 2254 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2255 #endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) 2257 #if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) 2258 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 2260 template <
typename Prop,
typename... SupportableProperties>
2262 execution::any_executor<SupportableProperties...>, Prop,
2264 execution::detail::supportable_properties<
2265 0, void(SupportableProperties...)>::template
2266 find_convertible_requirable_property<Prop>::value
2269 static const bool is_valid =
true;
2270 static const bool is_noexcept =
false;
2274 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2276 #define ASIO_PRIVATE_ANY_EXECUTOR_REQUIRE_MEMBER_DEF(n) \ 2277 template <typename Prop, ASIO_VARIADIC_TPARAMS(n)> \ 2278 struct require_member< \ 2279 execution::any_executor<ASIO_VARIADIC_TARGS(n)>, Prop, \ 2280 typename enable_if< \ 2281 execution::detail::supportable_properties< \ 2282 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 2283 find_convertible_requirable_property<Prop>::value \ 2286 static const bool is_valid = true; \ 2287 static const bool is_noexcept = false; \ 2288 typedef execution::any_executor<ASIO_VARIADIC_TARGS(n)> result_type; \ 2291 ASIO_VARIADIC_GENERATE(
2292 ASIO_PRIVATE_ANY_EXECUTOR_REQUIRE_MEMBER_DEF)
2293 #undef ASIO_PRIVATE_ANY_EXECUTOR_REQUIRE_MEMBER_DEF 2295 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2296 #endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) 2298 #if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) 2299 #if defined(ASIO_HAS_VARIADIC_TEMPLATES) 2301 template <
typename Prop,
typename... SupportableProperties>
2303 execution::any_executor<SupportableProperties...>, Prop,
2305 execution::detail::supportable_properties<
2306 0, void(SupportableProperties...)>::template
2307 find_convertible_preferable_property<Prop>::value
2310 static const bool is_valid =
true;
2311 static const bool is_noexcept =
false;
2315 #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2317 #define ASIO_PRIVATE_ANY_EXECUTOR_PREFER_FREE_DEF(n) \ 2318 template <typename Prop, ASIO_VARIADIC_TPARAMS(n)> \ 2319 struct prefer_member< \ 2320 execution::any_executor<ASIO_VARIADIC_TARGS(n)>, Prop, \ 2321 typename enable_if< \ 2322 execution::detail::supportable_properties< \ 2323 0, void(ASIO_VARIADIC_TARGS(n))>::template \ 2324 find_convertible_preferable_property<Prop>::value \ 2327 static const bool is_valid = true; \ 2328 static const bool is_noexcept = false; \ 2329 typedef execution::any_executor<ASIO_VARIADIC_TARGS(n)> result_type; \ 2332 ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_PREFER_FREE_DEF)
2333 #undef ASIO_PRIVATE_ANY_EXECUTOR_PREFER_FREE_DEF 2335 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) 2336 #endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) 2340 #endif // defined(GENERATING_DOCUMENTATION) 2344 #include "asio/detail/pop_options.hpp" 2346 #endif // ASIO_EXECUTION_ANY_EXECUTOR_HPP Definition: any_executor.hpp:249
Exception thrown when trying to access an empty polymorphic executor.
Definition: bad_executor.hpp:26
Definition: prefer_member.hpp:38
Definition: blocking.hpp:208
Definition: any_executor.hpp:804
Definition: any_executor.hpp:671
Definition: any_executor.hpp:275
Definition: query_member.hpp:38
Definition: any_executor.hpp:1197
Definition: can_prefer_free_prefer.cpp:21
Definition: any_executor.hpp:265
Definition: execute_member.hpp:38
Definition: type_traits.hpp:97
Definition: require_member.hpp:38
Definition: query.hpp:253
Definition: non_const_lvalue.hpp:27
Definition: any_executor.hpp:484
Definition: handler_work.hpp:46
Definition: any_executor.hpp:1118
Definition: any_executor.hpp:475
Definition: can_prefer_free_prefer.cpp:15
Definition: executor_function.hpp:125
Definition: any_executor.hpp:1176
Definition: executor_function.hpp:172
Definition: any_executor.hpp:240
Definition: any_executor.hpp:256
Definition: scoped_ptr.hpp:26
Definition: handler_work.hpp:37
Definition: any_io_executor.hpp:28
Definition: any_executor.hpp:631
Definition: equality_comparable.hpp:36
The is_executor trait detects whether a type T satisfies the execution::executor concept.
Definition: executor.hpp:109