blocking.hpp 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. //
  2. // execution/blocking.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_EXECUTION_BLOCKING_HPP
  11. #define BOOST_ASIO_EXECUTION_BLOCKING_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/detail/type_traits.hpp>
  17. #include <boost/asio/execution/executor.hpp>
  18. #include <boost/asio/is_applicable_property.hpp>
  19. #include <boost/asio/prefer.hpp>
  20. #include <boost/asio/query.hpp>
  21. #include <boost/asio/require.hpp>
  22. #include <boost/asio/traits/execute_member.hpp>
  23. #include <boost/asio/traits/query_free.hpp>
  24. #include <boost/asio/traits/query_member.hpp>
  25. #include <boost/asio/traits/query_static_constexpr_member.hpp>
  26. #include <boost/asio/traits/static_query.hpp>
  27. #include <boost/asio/traits/static_require.hpp>
  28. #include <boost/asio/detail/push_options.hpp>
  29. namespace boost {
  30. namespace asio {
  31. #if defined(GENERATING_DOCUMENTATION)
  32. namespace execution {
  33. /// A property to describe what guarantees an executor makes about the blocking
  34. /// behaviour of their execution functions.
  35. struct blocking_t
  36. {
  37. /// The blocking_t property applies to executors.
  38. template <typename T>
  39. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  40. /// The top-level blocking_t property cannot be required.
  41. static constexpr bool is_requirable = false;
  42. /// The top-level blocking_t property cannot be preferred.
  43. static constexpr bool is_preferable = false;
  44. /// The type returned by queries against an @c any_executor.
  45. typedef blocking_t polymorphic_query_result_type;
  46. /// A sub-property that indicates that invocation of an executor's execution
  47. /// function may block pending completion of one or more invocations of the
  48. /// submitted function object.
  49. struct possibly_t
  50. {
  51. /// The blocking_t::possibly_t property applies to executors.
  52. template <typename T>
  53. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  54. /// The blocking_t::possibly_t property can be required.
  55. static constexpr bool is_requirable = true;
  56. /// The blocking_t::possibly_t property can be preferred.
  57. static constexpr bool is_preferable = true;
  58. /// The type returned by queries against an @c any_executor.
  59. typedef blocking_t polymorphic_query_result_type;
  60. /// Default constructor.
  61. constexpr possibly_t();
  62. /// Get the value associated with a property object.
  63. /**
  64. * @returns possibly_t();
  65. */
  66. static constexpr blocking_t value();
  67. };
  68. /// A sub-property that indicates that invocation of an executor's execution
  69. /// function shall block until completion of all invocations of the submitted
  70. /// function object.
  71. struct always_t
  72. {
  73. /// The blocking_t::always_t property applies to executors.
  74. template <typename T>
  75. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  76. /// The blocking_t::always_t property can be required.
  77. static constexpr bool is_requirable = true;
  78. /// The blocking_t::always_t property can be preferred.
  79. static constexpr bool is_preferable = false;
  80. /// The type returned by queries against an @c any_executor.
  81. typedef blocking_t polymorphic_query_result_type;
  82. /// Default constructor.
  83. constexpr always_t();
  84. /// Get the value associated with a property object.
  85. /**
  86. * @returns always_t();
  87. */
  88. static constexpr blocking_t value();
  89. };
  90. /// A sub-property that indicates that invocation of an executor's execution
  91. /// function shall not block pending completion of the invocations of the
  92. /// submitted function object.
  93. struct never_t
  94. {
  95. /// The blocking_t::never_t property applies to executors.
  96. template <typename T>
  97. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  98. /// The blocking_t::never_t property can be required.
  99. static constexpr bool is_requirable = true;
  100. /// The blocking_t::never_t property can be preferred.
  101. static constexpr bool is_preferable = true;
  102. /// The type returned by queries against an @c any_executor.
  103. typedef blocking_t polymorphic_query_result_type;
  104. /// Default constructor.
  105. constexpr never_t();
  106. /// Get the value associated with a property object.
  107. /**
  108. * @returns never_t();
  109. */
  110. static constexpr blocking_t value();
  111. };
  112. /// A special value used for accessing the blocking_t::possibly_t property.
  113. static constexpr possibly_t possibly;
  114. /// A special value used for accessing the blocking_t::always_t property.
  115. static constexpr always_t always;
  116. /// A special value used for accessing the blocking_t::never_t property.
  117. static constexpr never_t never;
  118. /// Default constructor.
  119. constexpr blocking_t();
  120. /// Construct from a sub-property value.
  121. constexpr blocking_t(possibly_t);
  122. /// Construct from a sub-property value.
  123. constexpr blocking_t(always_t);
  124. /// Construct from a sub-property value.
  125. constexpr blocking_t(never_t);
  126. /// Compare property values for equality.
  127. friend constexpr bool operator==(
  128. const blocking_t& a, const blocking_t& b) noexcept;
  129. /// Compare property values for inequality.
  130. friend constexpr bool operator!=(
  131. const blocking_t& a, const blocking_t& b) noexcept;
  132. };
  133. /// A special value used for accessing the blocking_t property.
  134. constexpr blocking_t blocking;
  135. } // namespace execution
  136. #else // defined(GENERATING_DOCUMENTATION)
  137. namespace execution {
  138. namespace detail {
  139. namespace blocking {
  140. template <int I> struct possibly_t;
  141. template <int I> struct always_t;
  142. template <int I> struct never_t;
  143. } // namespace blocking
  144. namespace blocking_adaptation {
  145. template <int I> struct allowed_t;
  146. template <typename Executor, typename Function>
  147. void blocking_execute(
  148. Executor&& ex,
  149. Function&& func);
  150. } // namespace blocking_adaptation
  151. template <int I = 0>
  152. struct blocking_t
  153. {
  154. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  155. template <typename T>
  156. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  157. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  158. static constexpr bool is_requirable = false;
  159. static constexpr bool is_preferable = false;
  160. typedef blocking_t polymorphic_query_result_type;
  161. typedef detail::blocking::possibly_t<I> possibly_t;
  162. typedef detail::blocking::always_t<I> always_t;
  163. typedef detail::blocking::never_t<I> never_t;
  164. constexpr blocking_t()
  165. : value_(-1)
  166. {
  167. }
  168. constexpr blocking_t(possibly_t)
  169. : value_(0)
  170. {
  171. }
  172. constexpr blocking_t(always_t)
  173. : value_(1)
  174. {
  175. }
  176. constexpr blocking_t(never_t)
  177. : value_(2)
  178. {
  179. }
  180. template <typename T>
  181. struct proxy
  182. {
  183. #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  184. struct type
  185. {
  186. template <typename P>
  187. auto query(P&& p) const
  188. noexcept(
  189. noexcept(
  190. declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
  191. )
  192. )
  193. -> decltype(
  194. declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
  195. );
  196. };
  197. #else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  198. typedef T type;
  199. #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  200. };
  201. template <typename T>
  202. struct static_proxy
  203. {
  204. #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  205. struct type
  206. {
  207. template <typename P>
  208. static constexpr auto query(P&& p)
  209. noexcept(
  210. noexcept(
  211. conditional_t<true, T, P>::query(static_cast<P&&>(p))
  212. )
  213. )
  214. -> decltype(
  215. conditional_t<true, T, P>::query(static_cast<P&&>(p))
  216. )
  217. {
  218. return T::query(static_cast<P&&>(p));
  219. }
  220. };
  221. #else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  222. typedef T type;
  223. #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  224. };
  225. template <typename T>
  226. struct query_member :
  227. traits::query_member<typename proxy<T>::type, blocking_t> {};
  228. template <typename T>
  229. struct query_static_constexpr_member :
  230. traits::query_static_constexpr_member<
  231. typename static_proxy<T>::type, blocking_t> {};
  232. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  233. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  234. template <typename T>
  235. static constexpr
  236. typename query_static_constexpr_member<T>::result_type
  237. static_query()
  238. noexcept(query_static_constexpr_member<T>::is_noexcept)
  239. {
  240. return query_static_constexpr_member<T>::value();
  241. }
  242. template <typename T>
  243. static constexpr
  244. typename traits::static_query<T, possibly_t>::result_type
  245. static_query(
  246. enable_if_t<
  247. !query_static_constexpr_member<T>::is_valid
  248. >* = 0,
  249. enable_if_t<
  250. !query_member<T>::is_valid
  251. >* = 0,
  252. enable_if_t<
  253. traits::static_query<T, possibly_t>::is_valid
  254. >* = 0) noexcept
  255. {
  256. return traits::static_query<T, possibly_t>::value();
  257. }
  258. template <typename T>
  259. static constexpr
  260. typename traits::static_query<T, always_t>::result_type
  261. static_query(
  262. enable_if_t<
  263. !query_static_constexpr_member<T>::is_valid
  264. >* = 0,
  265. enable_if_t<
  266. !query_member<T>::is_valid
  267. >* = 0,
  268. enable_if_t<
  269. !traits::static_query<T, possibly_t>::is_valid
  270. >* = 0,
  271. enable_if_t<
  272. traits::static_query<T, always_t>::is_valid
  273. >* = 0) noexcept
  274. {
  275. return traits::static_query<T, always_t>::value();
  276. }
  277. template <typename T>
  278. static constexpr
  279. typename traits::static_query<T, never_t>::result_type
  280. static_query(
  281. enable_if_t<
  282. !query_static_constexpr_member<T>::is_valid
  283. >* = 0,
  284. enable_if_t<
  285. !query_member<T>::is_valid
  286. >* = 0,
  287. enable_if_t<
  288. !traits::static_query<T, possibly_t>::is_valid
  289. >* = 0,
  290. enable_if_t<
  291. !traits::static_query<T, always_t>::is_valid
  292. >* = 0,
  293. enable_if_t<
  294. traits::static_query<T, never_t>::is_valid
  295. >* = 0) noexcept
  296. {
  297. return traits::static_query<T, never_t>::value();
  298. }
  299. template <typename E, typename T = decltype(blocking_t::static_query<E>())>
  300. static constexpr const T static_query_v
  301. = blocking_t::static_query<E>();
  302. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  303. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  304. friend constexpr bool operator==(
  305. const blocking_t& a, const blocking_t& b)
  306. {
  307. return a.value_ == b.value_;
  308. }
  309. friend constexpr bool operator!=(
  310. const blocking_t& a, const blocking_t& b)
  311. {
  312. return a.value_ != b.value_;
  313. }
  314. struct convertible_from_blocking_t
  315. {
  316. constexpr convertible_from_blocking_t(blocking_t) {}
  317. };
  318. template <typename Executor>
  319. friend constexpr blocking_t query(
  320. const Executor& ex, convertible_from_blocking_t,
  321. enable_if_t<
  322. can_query<const Executor&, possibly_t>::value
  323. >* = 0)
  324. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  325. #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
  326. noexcept(is_nothrow_query<const Executor&, blocking_t<>::possibly_t>::value)
  327. #else // defined(BOOST_ASIO_MSVC)
  328. noexcept(is_nothrow_query<const Executor&, possibly_t>::value)
  329. #endif // defined(BOOST_ASIO_MSVC)
  330. #endif // !defined(__clang__)
  331. {
  332. return boost::asio::query(ex, possibly_t());
  333. }
  334. template <typename Executor>
  335. friend constexpr blocking_t query(
  336. const Executor& ex, convertible_from_blocking_t,
  337. enable_if_t<
  338. !can_query<const Executor&, possibly_t>::value
  339. >* = 0,
  340. enable_if_t<
  341. can_query<const Executor&, always_t>::value
  342. >* = 0)
  343. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  344. #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
  345. noexcept(is_nothrow_query<const Executor&, blocking_t<>::always_t>::value)
  346. #else // defined(BOOST_ASIO_MSVC)
  347. noexcept(is_nothrow_query<const Executor&, always_t>::value)
  348. #endif // defined(BOOST_ASIO_MSVC)
  349. #endif // !defined(__clang__)
  350. {
  351. return boost::asio::query(ex, always_t());
  352. }
  353. template <typename Executor>
  354. friend constexpr blocking_t query(
  355. const Executor& ex, convertible_from_blocking_t,
  356. enable_if_t<
  357. !can_query<const Executor&, possibly_t>::value
  358. >* = 0,
  359. enable_if_t<
  360. !can_query<const Executor&, always_t>::value
  361. >* = 0,
  362. enable_if_t<
  363. can_query<const Executor&, never_t>::value
  364. >* = 0)
  365. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  366. #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
  367. noexcept(is_nothrow_query<const Executor&, blocking_t<>::never_t>::value)
  368. #else // defined(BOOST_ASIO_MSVC)
  369. noexcept(is_nothrow_query<const Executor&, never_t>::value)
  370. #endif // defined(BOOST_ASIO_MSVC)
  371. #endif // !defined(__clang__)
  372. {
  373. return boost::asio::query(ex, never_t());
  374. }
  375. BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(possibly_t, possibly);
  376. BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(always_t, always);
  377. BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(never_t, never);
  378. private:
  379. int value_;
  380. };
  381. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  382. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  383. template <int I> template <typename E, typename T>
  384. const T blocking_t<I>::static_query_v;
  385. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  386. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  387. template <int I>
  388. const typename blocking_t<I>::possibly_t blocking_t<I>::possibly;
  389. template <int I>
  390. const typename blocking_t<I>::always_t blocking_t<I>::always;
  391. template <int I>
  392. const typename blocking_t<I>::never_t blocking_t<I>::never;
  393. namespace blocking {
  394. template <int I = 0>
  395. struct possibly_t
  396. {
  397. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  398. template <typename T>
  399. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  400. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  401. static constexpr bool is_requirable = true;
  402. static constexpr bool is_preferable = true;
  403. typedef blocking_t<I> polymorphic_query_result_type;
  404. constexpr possibly_t()
  405. {
  406. }
  407. template <typename T>
  408. struct query_member :
  409. traits::query_member<
  410. typename blocking_t<I>::template proxy<T>::type, possibly_t> {};
  411. template <typename T>
  412. struct query_static_constexpr_member :
  413. traits::query_static_constexpr_member<
  414. typename blocking_t<I>::template static_proxy<T>::type, possibly_t> {};
  415. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  416. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  417. template <typename T>
  418. static constexpr
  419. typename query_static_constexpr_member<T>::result_type
  420. static_query()
  421. noexcept(query_static_constexpr_member<T>::is_noexcept)
  422. {
  423. return query_static_constexpr_member<T>::value();
  424. }
  425. template <typename T>
  426. static constexpr possibly_t static_query(
  427. enable_if_t<
  428. !query_static_constexpr_member<T>::is_valid
  429. >* = 0,
  430. enable_if_t<
  431. !query_member<T>::is_valid
  432. >* = 0,
  433. enable_if_t<
  434. !traits::query_free<T, possibly_t>::is_valid
  435. >* = 0,
  436. enable_if_t<
  437. !can_query<T, always_t<I>>::value
  438. >* = 0,
  439. enable_if_t<
  440. !can_query<T, never_t<I>>::value
  441. >* = 0) noexcept
  442. {
  443. return possibly_t();
  444. }
  445. template <typename E, typename T = decltype(possibly_t::static_query<E>())>
  446. static constexpr const T static_query_v
  447. = possibly_t::static_query<E>();
  448. #endif // defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  449. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  450. static constexpr blocking_t<I> value()
  451. {
  452. return possibly_t();
  453. }
  454. friend constexpr bool operator==(
  455. const possibly_t&, const possibly_t&)
  456. {
  457. return true;
  458. }
  459. friend constexpr bool operator!=(
  460. const possibly_t&, const possibly_t&)
  461. {
  462. return false;
  463. }
  464. friend constexpr bool operator==(
  465. const possibly_t&, const always_t<I>&)
  466. {
  467. return false;
  468. }
  469. friend constexpr bool operator!=(
  470. const possibly_t&, const always_t<I>&)
  471. {
  472. return true;
  473. }
  474. friend constexpr bool operator==(
  475. const possibly_t&, const never_t<I>&)
  476. {
  477. return false;
  478. }
  479. friend constexpr bool operator!=(
  480. const possibly_t&, const never_t<I>&)
  481. {
  482. return true;
  483. }
  484. };
  485. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  486. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  487. template <int I> template <typename E, typename T>
  488. const T possibly_t<I>::static_query_v;
  489. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  490. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  491. template <typename Executor>
  492. class adapter
  493. {
  494. public:
  495. adapter(int, const Executor& e) noexcept
  496. : executor_(e)
  497. {
  498. }
  499. adapter(const adapter& other) noexcept
  500. : executor_(other.executor_)
  501. {
  502. }
  503. adapter(adapter&& other) noexcept
  504. : executor_(static_cast<Executor&&>(other.executor_))
  505. {
  506. }
  507. template <int I>
  508. static constexpr always_t<I> query(blocking_t<I>) noexcept
  509. {
  510. return always_t<I>();
  511. }
  512. template <int I>
  513. static constexpr always_t<I> query(possibly_t<I>) noexcept
  514. {
  515. return always_t<I>();
  516. }
  517. template <int I>
  518. static constexpr always_t<I> query(always_t<I>) noexcept
  519. {
  520. return always_t<I>();
  521. }
  522. template <int I>
  523. static constexpr always_t<I> query(never_t<I>) noexcept
  524. {
  525. return always_t<I>();
  526. }
  527. template <typename Property>
  528. enable_if_t<
  529. can_query<const Executor&, Property>::value,
  530. query_result_t<const Executor&, Property>
  531. > query(const Property& p) const
  532. noexcept(is_nothrow_query<const Executor&, Property>::value)
  533. {
  534. return boost::asio::query(executor_, p);
  535. }
  536. template <int I>
  537. enable_if_t<
  538. can_require<const Executor&, possibly_t<I>>::value,
  539. require_result_t<const Executor&, possibly_t<I>>
  540. > require(possibly_t<I>) const noexcept
  541. {
  542. return boost::asio::require(executor_, possibly_t<I>());
  543. }
  544. template <int I>
  545. enable_if_t<
  546. can_require<const Executor&, never_t<I>>::value,
  547. require_result_t<const Executor&, never_t<I>>
  548. > require(never_t<I>) const noexcept
  549. {
  550. return boost::asio::require(executor_, never_t<I>());
  551. }
  552. template <typename Property>
  553. enable_if_t<
  554. can_require<const Executor&, Property>::value,
  555. adapter<decay_t<require_result_t<const Executor&, Property>>>
  556. > require(const Property& p) const
  557. noexcept(is_nothrow_require<const Executor&, Property>::value)
  558. {
  559. return adapter<decay_t<require_result_t<const Executor&, Property>>>(
  560. 0, boost::asio::require(executor_, p));
  561. }
  562. template <typename Property>
  563. enable_if_t<
  564. can_prefer<const Executor&, Property>::value,
  565. adapter<decay_t<prefer_result_t<const Executor&, Property>>>
  566. > prefer(const Property& p) const
  567. noexcept(is_nothrow_prefer<const Executor&, Property>::value)
  568. {
  569. return adapter<decay_t<prefer_result_t<const Executor&, Property>>>(
  570. 0, boost::asio::prefer(executor_, p));
  571. }
  572. template <typename Function>
  573. enable_if_t<
  574. traits::execute_member<const Executor&, Function>::is_valid
  575. > execute(Function&& f) const
  576. {
  577. blocking_adaptation::blocking_execute(
  578. executor_, static_cast<Function&&>(f));
  579. }
  580. friend bool operator==(const adapter& a, const adapter& b) noexcept
  581. {
  582. return a.executor_ == b.executor_;
  583. }
  584. friend bool operator!=(const adapter& a, const adapter& b) noexcept
  585. {
  586. return a.executor_ != b.executor_;
  587. }
  588. private:
  589. Executor executor_;
  590. };
  591. template <int I = 0>
  592. struct always_t
  593. {
  594. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  595. template <typename T>
  596. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  597. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  598. static constexpr bool is_requirable = true;
  599. static constexpr bool is_preferable = false;
  600. typedef blocking_t<I> polymorphic_query_result_type;
  601. constexpr always_t()
  602. {
  603. }
  604. template <typename T>
  605. struct query_member :
  606. traits::query_member<
  607. typename blocking_t<I>::template proxy<T>::type, always_t> {};
  608. template <typename T>
  609. struct query_static_constexpr_member :
  610. traits::query_static_constexpr_member<
  611. typename blocking_t<I>::template static_proxy<T>::type, always_t> {};
  612. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  613. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  614. template <typename T>
  615. static constexpr typename query_static_constexpr_member<T>::result_type
  616. static_query()
  617. noexcept(query_static_constexpr_member<T>::is_noexcept)
  618. {
  619. return query_static_constexpr_member<T>::value();
  620. }
  621. template <typename E, typename T = decltype(always_t::static_query<E>())>
  622. static constexpr const T static_query_v = always_t::static_query<E>();
  623. #endif // defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  624. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  625. static constexpr blocking_t<I> value()
  626. {
  627. return always_t();
  628. }
  629. friend constexpr bool operator==(
  630. const always_t&, const always_t&)
  631. {
  632. return true;
  633. }
  634. friend constexpr bool operator!=(
  635. const always_t&, const always_t&)
  636. {
  637. return false;
  638. }
  639. friend constexpr bool operator==(
  640. const always_t&, const possibly_t<I>&)
  641. {
  642. return false;
  643. }
  644. friend constexpr bool operator!=(
  645. const always_t&, const possibly_t<I>&)
  646. {
  647. return true;
  648. }
  649. friend constexpr bool operator==(
  650. const always_t&, const never_t<I>&)
  651. {
  652. return false;
  653. }
  654. friend constexpr bool operator!=(
  655. const always_t&, const never_t<I>&)
  656. {
  657. return true;
  658. }
  659. template <typename Executor>
  660. friend adapter<Executor> require(
  661. const Executor& e, const always_t&,
  662. enable_if_t<
  663. is_executor<Executor>::value
  664. >* = 0,
  665. enable_if_t<
  666. traits::static_require<
  667. const Executor&,
  668. blocking_adaptation::allowed_t<0>
  669. >::is_valid
  670. >* = 0)
  671. {
  672. return adapter<Executor>(0, e);
  673. }
  674. };
  675. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  676. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  677. template <int I> template <typename E, typename T>
  678. const T always_t<I>::static_query_v;
  679. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  680. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  681. template <int I>
  682. struct never_t
  683. {
  684. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  685. template <typename T>
  686. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  687. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  688. static constexpr bool is_requirable = true;
  689. static constexpr bool is_preferable = true;
  690. typedef blocking_t<I> polymorphic_query_result_type;
  691. constexpr never_t()
  692. {
  693. }
  694. template <typename T>
  695. struct query_member :
  696. traits::query_member<
  697. typename blocking_t<I>::template proxy<T>::type, never_t> {};
  698. template <typename T>
  699. struct query_static_constexpr_member :
  700. traits::query_static_constexpr_member<
  701. typename blocking_t<I>::template static_proxy<T>::type, never_t> {};
  702. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  703. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  704. template <typename T>
  705. static constexpr
  706. typename query_static_constexpr_member<T>::result_type
  707. static_query()
  708. noexcept(query_static_constexpr_member<T>::is_noexcept)
  709. {
  710. return query_static_constexpr_member<T>::value();
  711. }
  712. template <typename E, typename T = decltype(never_t::static_query<E>())>
  713. static constexpr const T static_query_v
  714. = never_t::static_query<E>();
  715. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  716. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  717. static constexpr blocking_t<I> value()
  718. {
  719. return never_t();
  720. }
  721. friend constexpr bool operator==(const never_t&, const never_t&)
  722. {
  723. return true;
  724. }
  725. friend constexpr bool operator!=(const never_t&, const never_t&)
  726. {
  727. return false;
  728. }
  729. friend constexpr bool operator==(const never_t&, const possibly_t<I>&)
  730. {
  731. return false;
  732. }
  733. friend constexpr bool operator!=(const never_t&, const possibly_t<I>&)
  734. {
  735. return true;
  736. }
  737. friend constexpr bool operator==(const never_t&, const always_t<I>&)
  738. {
  739. return false;
  740. }
  741. friend constexpr bool operator!=(const never_t&, const always_t<I>&)
  742. {
  743. return true;
  744. }
  745. };
  746. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  747. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  748. template <int I> template <typename E, typename T>
  749. const T never_t<I>::static_query_v;
  750. #endif // defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  751. } // namespace blocking
  752. } // namespace detail
  753. typedef detail::blocking_t<> blocking_t;
  754. BOOST_ASIO_INLINE_VARIABLE constexpr blocking_t blocking;
  755. } // namespace execution
  756. #if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  757. template <typename T>
  758. struct is_applicable_property<T, execution::blocking_t>
  759. : integral_constant<bool, execution::is_executor<T>::value>
  760. {
  761. };
  762. template <typename T>
  763. struct is_applicable_property<T, execution::blocking_t::possibly_t>
  764. : integral_constant<bool, execution::is_executor<T>::value>
  765. {
  766. };
  767. template <typename T>
  768. struct is_applicable_property<T, execution::blocking_t::always_t>
  769. : integral_constant<bool, execution::is_executor<T>::value>
  770. {
  771. };
  772. template <typename T>
  773. struct is_applicable_property<T, execution::blocking_t::never_t>
  774. : integral_constant<bool, execution::is_executor<T>::value>
  775. {
  776. };
  777. #endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  778. namespace traits {
  779. #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
  780. template <typename T>
  781. struct query_free_default<T, execution::blocking_t,
  782. enable_if_t<
  783. can_query<T, execution::blocking_t::possibly_t>::value
  784. >>
  785. {
  786. static constexpr bool is_valid = true;
  787. static constexpr bool is_noexcept =
  788. is_nothrow_query<T, execution::blocking_t::possibly_t>::value;
  789. typedef execution::blocking_t result_type;
  790. };
  791. template <typename T>
  792. struct query_free_default<T, execution::blocking_t,
  793. enable_if_t<
  794. !can_query<T, execution::blocking_t::possibly_t>::value
  795. && can_query<T, execution::blocking_t::always_t>::value
  796. >>
  797. {
  798. static constexpr bool is_valid = true;
  799. static constexpr bool is_noexcept =
  800. is_nothrow_query<T, execution::blocking_t::always_t>::value;
  801. typedef execution::blocking_t result_type;
  802. };
  803. template <typename T>
  804. struct query_free_default<T, execution::blocking_t,
  805. enable_if_t<
  806. !can_query<T, execution::blocking_t::possibly_t>::value
  807. && !can_query<T, execution::blocking_t::always_t>::value
  808. && can_query<T, execution::blocking_t::never_t>::value
  809. >>
  810. {
  811. static constexpr bool is_valid = true;
  812. static constexpr bool is_noexcept =
  813. is_nothrow_query<T, execution::blocking_t::never_t>::value;
  814. typedef execution::blocking_t result_type;
  815. };
  816. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
  817. #if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  818. || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  819. template <typename T>
  820. struct static_query<T, execution::blocking_t,
  821. enable_if_t<
  822. execution::detail::blocking_t<0>::
  823. query_static_constexpr_member<T>::is_valid
  824. >>
  825. {
  826. static constexpr bool is_valid = true;
  827. static constexpr bool is_noexcept = true;
  828. typedef typename execution::detail::blocking_t<0>::
  829. query_static_constexpr_member<T>::result_type result_type;
  830. static constexpr result_type value()
  831. {
  832. return execution::blocking_t::query_static_constexpr_member<T>::value();
  833. }
  834. };
  835. template <typename T>
  836. struct static_query<T, execution::blocking_t,
  837. enable_if_t<
  838. !execution::detail::blocking_t<0>::
  839. query_static_constexpr_member<T>::is_valid
  840. && !execution::detail::blocking_t<0>::
  841. query_member<T>::is_valid
  842. && traits::static_query<T, execution::blocking_t::possibly_t>::is_valid
  843. >>
  844. {
  845. static constexpr bool is_valid = true;
  846. static constexpr bool is_noexcept = true;
  847. typedef typename traits::static_query<T,
  848. execution::blocking_t::possibly_t>::result_type result_type;
  849. static constexpr result_type value()
  850. {
  851. return traits::static_query<T, execution::blocking_t::possibly_t>::value();
  852. }
  853. };
  854. template <typename T>
  855. struct static_query<T, execution::blocking_t,
  856. enable_if_t<
  857. !execution::detail::blocking_t<0>::
  858. query_static_constexpr_member<T>::is_valid
  859. && !execution::detail::blocking_t<0>::
  860. query_member<T>::is_valid
  861. && !traits::static_query<T, execution::blocking_t::possibly_t>::is_valid
  862. && traits::static_query<T, execution::blocking_t::always_t>::is_valid
  863. >>
  864. {
  865. static constexpr bool is_valid = true;
  866. static constexpr bool is_noexcept = true;
  867. typedef typename traits::static_query<T,
  868. execution::blocking_t::always_t>::result_type result_type;
  869. static constexpr result_type value()
  870. {
  871. return traits::static_query<T, execution::blocking_t::always_t>::value();
  872. }
  873. };
  874. template <typename T>
  875. struct static_query<T, execution::blocking_t,
  876. enable_if_t<
  877. !execution::detail::blocking_t<0>::
  878. query_static_constexpr_member<T>::is_valid
  879. && !execution::detail::blocking_t<0>::
  880. query_member<T>::is_valid
  881. && !traits::static_query<T, execution::blocking_t::possibly_t>::is_valid
  882. && !traits::static_query<T, execution::blocking_t::always_t>::is_valid
  883. && traits::static_query<T, execution::blocking_t::never_t>::is_valid
  884. >>
  885. {
  886. static constexpr bool is_valid = true;
  887. static constexpr bool is_noexcept = true;
  888. typedef typename traits::static_query<T,
  889. execution::blocking_t::never_t>::result_type result_type;
  890. static constexpr result_type value()
  891. {
  892. return traits::static_query<T, execution::blocking_t::never_t>::value();
  893. }
  894. };
  895. template <typename T>
  896. struct static_query<T, execution::blocking_t::possibly_t,
  897. enable_if_t<
  898. execution::detail::blocking::possibly_t<0>::
  899. query_static_constexpr_member<T>::is_valid
  900. >>
  901. {
  902. static constexpr bool is_valid = true;
  903. static constexpr bool is_noexcept = true;
  904. typedef typename execution::detail::blocking::possibly_t<0>::
  905. query_static_constexpr_member<T>::result_type result_type;
  906. static constexpr result_type value()
  907. {
  908. return execution::detail::blocking::possibly_t<0>::
  909. query_static_constexpr_member<T>::value();
  910. }
  911. };
  912. template <typename T>
  913. struct static_query<T, execution::blocking_t::possibly_t,
  914. enable_if_t<
  915. !execution::detail::blocking::possibly_t<0>::
  916. query_static_constexpr_member<T>::is_valid
  917. && !execution::detail::blocking::possibly_t<0>::
  918. query_member<T>::is_valid
  919. && !traits::query_free<T, execution::blocking_t::possibly_t>::is_valid
  920. && !can_query<T, execution::blocking_t::always_t>::value
  921. && !can_query<T, execution::blocking_t::never_t>::value
  922. >>
  923. {
  924. static constexpr bool is_valid = true;
  925. static constexpr bool is_noexcept = true;
  926. typedef execution::blocking_t::possibly_t result_type;
  927. static constexpr result_type value()
  928. {
  929. return result_type();
  930. }
  931. };
  932. template <typename T>
  933. struct static_query<T, execution::blocking_t::always_t,
  934. enable_if_t<
  935. execution::detail::blocking::always_t<0>::
  936. query_static_constexpr_member<T>::is_valid
  937. >>
  938. {
  939. static constexpr bool is_valid = true;
  940. static constexpr bool is_noexcept = true;
  941. typedef typename execution::detail::blocking::always_t<0>::
  942. query_static_constexpr_member<T>::result_type result_type;
  943. static constexpr result_type value()
  944. {
  945. return execution::detail::blocking::always_t<0>::
  946. query_static_constexpr_member<T>::value();
  947. }
  948. };
  949. template <typename T>
  950. struct static_query<T, execution::blocking_t::never_t,
  951. enable_if_t<
  952. execution::detail::blocking::never_t<0>::
  953. query_static_constexpr_member<T>::is_valid
  954. >>
  955. {
  956. static constexpr bool is_valid = true;
  957. static constexpr bool is_noexcept = true;
  958. typedef typename execution::detail::blocking::never_t<0>::
  959. query_static_constexpr_member<T>::result_type result_type;
  960. static constexpr result_type value()
  961. {
  962. return execution::detail::blocking::never_t<0>::
  963. query_static_constexpr_member<T>::value();
  964. }
  965. };
  966. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  967. // || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  968. #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT)
  969. template <typename T>
  970. struct require_free_default<T, execution::blocking_t::always_t,
  971. enable_if_t<
  972. is_same<T, decay_t<T>>::value
  973. && execution::is_executor<T>::value
  974. && traits::static_require<
  975. const T&,
  976. execution::detail::blocking_adaptation::allowed_t<0>
  977. >::is_valid
  978. >>
  979. {
  980. static constexpr bool is_valid = true;
  981. static constexpr bool is_noexcept = false;
  982. typedef execution::detail::blocking::adapter<T> result_type;
  983. };
  984. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT)
  985. #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
  986. template <typename Executor>
  987. struct equality_comparable<
  988. execution::detail::blocking::adapter<Executor>>
  989. {
  990. static constexpr bool is_valid = true;
  991. static constexpr bool is_noexcept = true;
  992. };
  993. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
  994. #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
  995. template <typename Executor, typename Function>
  996. struct execute_member<
  997. execution::detail::blocking::adapter<Executor>, Function>
  998. {
  999. static constexpr bool is_valid = true;
  1000. static constexpr bool is_noexcept = false;
  1001. typedef void result_type;
  1002. };
  1003. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
  1004. #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  1005. template <typename Executor, int I>
  1006. struct query_static_constexpr_member<
  1007. execution::detail::blocking::adapter<Executor>,
  1008. execution::detail::blocking_t<I>>
  1009. {
  1010. static constexpr bool is_valid = true;
  1011. static constexpr bool is_noexcept = true;
  1012. typedef execution::blocking_t::always_t result_type;
  1013. static constexpr result_type value() noexcept
  1014. {
  1015. return result_type();
  1016. }
  1017. };
  1018. template <typename Executor, int I>
  1019. struct query_static_constexpr_member<
  1020. execution::detail::blocking::adapter<Executor>,
  1021. execution::detail::blocking::always_t<I>>
  1022. {
  1023. static constexpr bool is_valid = true;
  1024. static constexpr bool is_noexcept = true;
  1025. typedef execution::blocking_t::always_t result_type;
  1026. static constexpr result_type value() noexcept
  1027. {
  1028. return result_type();
  1029. }
  1030. };
  1031. template <typename Executor, int I>
  1032. struct query_static_constexpr_member<
  1033. execution::detail::blocking::adapter<Executor>,
  1034. execution::detail::blocking::possibly_t<I>>
  1035. {
  1036. static constexpr bool is_valid = true;
  1037. static constexpr bool is_noexcept = true;
  1038. typedef execution::blocking_t::always_t result_type;
  1039. static constexpr result_type value() noexcept
  1040. {
  1041. return result_type();
  1042. }
  1043. };
  1044. template <typename Executor, int I>
  1045. struct query_static_constexpr_member<
  1046. execution::detail::blocking::adapter<Executor>,
  1047. execution::detail::blocking::never_t<I>>
  1048. {
  1049. static constexpr bool is_valid = true;
  1050. static constexpr bool is_noexcept = true;
  1051. typedef execution::blocking_t::always_t result_type;
  1052. static constexpr result_type value() noexcept
  1053. {
  1054. return result_type();
  1055. }
  1056. };
  1057. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  1058. #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  1059. template <typename Executor, typename Property>
  1060. struct query_member<
  1061. execution::detail::blocking::adapter<Executor>, Property,
  1062. enable_if_t<
  1063. can_query<const Executor&, Property>::value
  1064. >>
  1065. {
  1066. static constexpr bool is_valid = true;
  1067. static constexpr bool is_noexcept =
  1068. is_nothrow_query<Executor, Property>::value;
  1069. typedef query_result_t<Executor, Property> result_type;
  1070. };
  1071. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  1072. #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
  1073. template <typename Executor, int I>
  1074. struct require_member<
  1075. execution::detail::blocking::adapter<Executor>,
  1076. execution::detail::blocking::possibly_t<I>,
  1077. enable_if_t<
  1078. can_require<
  1079. const Executor&,
  1080. execution::detail::blocking::possibly_t<I>
  1081. >::value
  1082. >>
  1083. {
  1084. static constexpr bool is_valid = true;
  1085. static constexpr bool is_noexcept =
  1086. is_nothrow_require<const Executor&,
  1087. execution::detail::blocking::possibly_t<I>>::value;
  1088. typedef require_result_t<const Executor&,
  1089. execution::detail::blocking::possibly_t<I>> result_type;
  1090. };
  1091. template <typename Executor, int I>
  1092. struct require_member<
  1093. execution::detail::blocking::adapter<Executor>,
  1094. execution::detail::blocking::never_t<I>,
  1095. enable_if_t<
  1096. can_require<
  1097. const Executor&,
  1098. execution::detail::blocking::never_t<I>
  1099. >::value
  1100. >>
  1101. {
  1102. static constexpr bool is_valid = true;
  1103. static constexpr bool is_noexcept =
  1104. is_nothrow_require<const Executor&,
  1105. execution::detail::blocking::never_t<I>>::value;
  1106. typedef require_result_t<const Executor&,
  1107. execution::detail::blocking::never_t<I>> result_type;
  1108. };
  1109. template <typename Executor, typename Property>
  1110. struct require_member<
  1111. execution::detail::blocking::adapter<Executor>, Property,
  1112. enable_if_t<
  1113. can_require<const Executor&, Property>::value
  1114. >>
  1115. {
  1116. static constexpr bool is_valid = true;
  1117. static constexpr bool is_noexcept =
  1118. is_nothrow_require<Executor, Property>::value;
  1119. typedef execution::detail::blocking::adapter<
  1120. decay_t<require_result_t<Executor, Property>>> result_type;
  1121. };
  1122. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
  1123. #if !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
  1124. template <typename Executor, typename Property>
  1125. struct prefer_member<
  1126. execution::detail::blocking::adapter<Executor>, Property,
  1127. enable_if_t<
  1128. can_prefer<const Executor&, Property>::value
  1129. >>
  1130. {
  1131. static constexpr bool is_valid = true;
  1132. static constexpr bool is_noexcept =
  1133. is_nothrow_prefer<Executor, Property>::value;
  1134. typedef execution::detail::blocking::adapter<
  1135. decay_t<prefer_result_t<Executor, Property>>> result_type;
  1136. };
  1137. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
  1138. } // namespace traits
  1139. #endif // defined(GENERATING_DOCUMENTATION)
  1140. } // namespace asio
  1141. } // namespace boost
  1142. #include <boost/asio/detail/pop_options.hpp>
  1143. #endif // BOOST_ASIO_EXECUTION_BLOCKING_HPP