blocking_adaptation.hpp 36 KB

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