invoker.hpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. // Copyright (C) 2012 Vicente J. Botet Escriba
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // 2013/04 Vicente J. Botet Escriba
  6. // Provide implementation up to 9 parameters when BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined.
  7. // Make use of Boost.Move
  8. // Make use of Boost.Tuple (movable)
  9. // 2012/11 Vicente J. Botet Escriba
  10. // Adapt to boost libc++ implementation
  11. //===----------------------------------------------------------------------===//
  12. //
  13. // The LLVM Compiler Infrastructure
  14. //
  15. // This file is dual licensed under the MIT and the University of Illinois Open
  16. // Source Licenses. See LICENSE.TXT for details.
  17. //
  18. // The invoker code is based on the one from libcxx.
  19. //===----------------------------------------------------------------------===//
  20. #ifndef BOOST_THREAD_DETAIL_INVOKER_HPP
  21. #define BOOST_THREAD_DETAIL_INVOKER_HPP
  22. #include <boost/config.hpp>
  23. #include <boost/utility/result_of.hpp>
  24. #include <boost/thread/detail/move.hpp>
  25. #include <boost/thread/detail/invoke.hpp>
  26. #include <boost/thread/detail/make_tuple_indices.hpp>
  27. #include <boost/thread/csbl/tuple.hpp>
  28. #include <boost/tuple/tuple.hpp>
  29. #include <boost/thread/detail/variadic_header.hpp>
  30. namespace boost
  31. {
  32. namespace detail
  33. {
  34. #if defined(BOOST_THREAD_PROVIDES_INVOKE) && ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && ! defined(BOOST_NO_CXX11_HDR_TUPLE)
  35. template <class Fp, class ... Args>
  36. class invoker
  37. {
  38. //typedef typename decay<Fp>::type Fpd;
  39. //typedef tuple<typename decay<Args>::type...> Argsd;
  40. //csbl::tuple<Fpd, Argsd...> f_;
  41. csbl::tuple<Fp, Args...> f_;
  42. public:
  43. BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker)
  44. //typedef typename invoke_of<_Fp, _Args...>::type Rp;
  45. typedef typename result_of<Fp(Args...)>::type result_type;
  46. template <class F, class ... As>
  47. BOOST_SYMBOL_VISIBLE
  48. explicit invoker(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args)
  49. : f_(boost::forward<F>(f), boost::forward<As>(args)...)
  50. {}
  51. BOOST_SYMBOL_VISIBLE
  52. invoker(BOOST_THREAD_RV_REF(invoker) f) : f_(boost::move(BOOST_THREAD_RV(f).f_))
  53. {}
  54. BOOST_SYMBOL_VISIBLE
  55. invoker( const invoker& f) : f_(f.f_)
  56. {}
  57. BOOST_SYMBOL_VISIBLE
  58. invoker& operator=(BOOST_THREAD_RV_REF(invoker) f)
  59. {
  60. if (this != &f)
  61. {
  62. f_ = boost::move(BOOST_THREAD_RV(f).f_);
  63. }
  64. return *this;
  65. }
  66. BOOST_SYMBOL_VISIBLE
  67. invoker& operator=( BOOST_THREAD_COPY_ASSIGN_REF(invoker) f)
  68. {
  69. if (this != &f)
  70. {
  71. f_ = f.f_;
  72. }
  73. return *this;
  74. }
  75. result_type operator()()
  76. {
  77. typedef typename make_tuple_indices<1+sizeof...(Args), 1>::type Index;
  78. return execute(Index());
  79. }
  80. private:
  81. template <size_t ...Indices>
  82. result_type
  83. execute(tuple_indices<Indices...>)
  84. {
  85. return detail::invoke(boost::move(csbl::get<0>(f_)), boost::move(csbl::get<Indices>(f_))...);
  86. }
  87. };
  88. template <class R, class Fp, class ... Args>
  89. class invoker_ret
  90. {
  91. //typedef typename decay<Fp>::type Fpd;
  92. //typedef tuple<typename decay<Args>::type...> Argsd;
  93. //csbl::tuple<Fpd, Argsd...> f_;
  94. csbl::tuple<Fp, Args...> f_;
  95. public:
  96. BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker_ret)
  97. typedef R result_type;
  98. template <class F, class ... As>
  99. BOOST_SYMBOL_VISIBLE
  100. explicit invoker_ret(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args)
  101. : f_(boost::forward<F>(f), boost::forward<As>(args)...)
  102. {}
  103. BOOST_SYMBOL_VISIBLE
  104. invoker_ret(BOOST_THREAD_RV_REF(invoker_ret) f) : f_(boost::move(BOOST_THREAD_RV(f).f_))
  105. {}
  106. result_type operator()()
  107. {
  108. typedef typename make_tuple_indices<1+sizeof...(Args), 1>::type Index;
  109. return execute(Index());
  110. }
  111. private:
  112. template <size_t ...Indices>
  113. result_type
  114. execute(tuple_indices<Indices...>)
  115. {
  116. return detail::invoke<R>(boost::move(csbl::get<0>(f_)), boost::move(csbl::get<Indices>(f_))...);
  117. }
  118. };
  119. //BOOST_THREAD_DCL_MOVABLE_BEG(X) invoker<Fp> BOOST_THREAD_DCL_MOVABLE_END
  120. #else
  121. #if ! defined BOOST_MSVC && defined(BOOST_THREAD_PROVIDES_INVOKE)
  122. #define BOOST_THREAD_RV_REF_ARG_T(z, n, unused) BOOST_PP_COMMA_IF(n) BOOST_THREAD_RV_REF(Arg##n)
  123. #define BOOST_THREAD_RV_REF_A_T(z, n, unused) BOOST_PP_COMMA_IF(n) BOOST_THREAD_RV_REF(A##n)
  124. #define BOOST_THREAD_RV_REF_ARG(z, n, unused) , BOOST_THREAD_RV_REF(Arg##n) arg##n
  125. #define BOOST_THREAD_FWD_REF_A(z, n, unused) , BOOST_THREAD_FWD_REF(A##n) arg##n
  126. #define BOOST_THREAD_FWD_REF_ARG(z, n, unused) , BOOST_THREAD_FWD_REF(Arg##n) arg##n
  127. #define BOOST_THREAD_FWD_PARAM(z, n, unused) , boost::forward<Arg##n>(arg##n)
  128. #define BOOST_THREAD_FWD_PARAM_A(z, n, unused) , boost::forward<A##n>(arg##n)
  129. #define BOOST_THREAD_DCL(z, n, unused) Arg##n v##n;
  130. #define BOOST_THREAD_MOVE_PARAM(z, n, unused) , v##n(boost::move(arg##n))
  131. #define BOOST_THREAD_FORWARD_PARAM_A(z, n, unused) , v##n(boost::forward<A##n>(arg##n))
  132. #define BOOST_THREAD_MOVE_RHS_PARAM(z, n, unused) , v##n(boost::move(x.v##n))
  133. #define BOOST_THREAD_MOVE_DCL(z, n, unused) , boost::move(v##n)
  134. #define BOOST_THREAD_MOVE_DCL_T(z, n, unused) BOOST_PP_COMMA_IF(n) boost::move(v##n)
  135. #define BOOST_THREAD_ARG_DEF(z, n, unused) , class Arg##n = tuples::null_type
  136. template <class Fp, class Arg = tuples::null_type
  137. BOOST_PP_REPEAT(BOOST_THREAD_MAX_ARGS, BOOST_THREAD_ARG_DEF, ~)
  138. >
  139. class invoker;
  140. #define BOOST_THREAD_ASYNC_FUNCT(z, n, unused) \
  141. template <class Fp BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class Arg) > \
  142. class invoker<Fp BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Arg)> \
  143. { \
  144. Fp fp_; \
  145. BOOST_PP_REPEAT(n, BOOST_THREAD_DCL, ~) \
  146. public: \
  147. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) \
  148. typedef typename result_of<Fp(BOOST_PP_ENUM_PARAMS(n, Arg))>::type result_type; \
  149. \
  150. template <class F BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) > \
  151. BOOST_SYMBOL_VISIBLE \
  152. explicit invoker(BOOST_THREAD_FWD_REF(F) f \
  153. BOOST_PP_REPEAT(n, BOOST_THREAD_FWD_REF_A, ~) \
  154. ) \
  155. : fp_(boost::forward<F>(f)) \
  156. BOOST_PP_REPEAT(n, BOOST_THREAD_FORWARD_PARAM_A, ~) \
  157. {} \
  158. \
  159. BOOST_SYMBOL_VISIBLE \
  160. invoker(BOOST_THREAD_RV_REF(invoker) x) \
  161. : fp_(boost::move(x.fp_)) \
  162. BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_RHS_PARAM, ~) \
  163. {} \
  164. \
  165. result_type operator()() { \
  166. return detail::invoke(boost::move(fp_) \
  167. BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_DCL, ~) \
  168. ); \
  169. } \
  170. }; \
  171. \
  172. template <class R BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class Arg) > \
  173. class invoker<R(*)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_ARG_T, ~)) BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Arg)> \
  174. { \
  175. typedef R(*Fp)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_ARG_T, ~)); \
  176. Fp fp_; \
  177. BOOST_PP_REPEAT(n, BOOST_THREAD_DCL, ~) \
  178. public: \
  179. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) \
  180. typedef typename result_of<Fp(BOOST_PP_ENUM_PARAMS(n, Arg))>::type result_type; \
  181. \
  182. template <class R2 BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) > \
  183. BOOST_SYMBOL_VISIBLE \
  184. explicit invoker(R2(*f)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_A_T, ~)) \
  185. BOOST_PP_REPEAT(n, BOOST_THREAD_FWD_REF_A, ~) \
  186. ) \
  187. : fp_(f) \
  188. BOOST_PP_REPEAT(n, BOOST_THREAD_FORWARD_PARAM_A, ~) \
  189. {} \
  190. \
  191. BOOST_SYMBOL_VISIBLE \
  192. invoker(BOOST_THREAD_RV_REF(invoker) x) \
  193. : fp_(x.fp_) \
  194. BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_RHS_PARAM, ~) \
  195. {} \
  196. \
  197. result_type operator()() { \
  198. return fp_( \
  199. BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_DCL_T, ~) \
  200. ); \
  201. } \
  202. };
  203. BOOST_PP_REPEAT(BOOST_THREAD_MAX_ARGS, BOOST_THREAD_ASYNC_FUNCT, ~)
  204. #undef BOOST_THREAD_RV_REF_ARG_T
  205. #undef BOOST_THREAD_RV_REF_ARG
  206. #undef BOOST_THREAD_FWD_REF_ARG
  207. #undef BOOST_THREAD_FWD_REF_A
  208. #undef BOOST_THREAD_FWD_PARAM
  209. #undef BOOST_THREAD_FWD_PARAM_A
  210. #undef BOOST_THREAD_DCL
  211. #undef BOOST_THREAD_MOVE_PARAM
  212. #undef BOOST_THREAD_MOVE_RHS_PARAM
  213. #undef BOOST_THREAD_MOVE_DCL
  214. #undef BOOST_THREAD_ARG_DEF
  215. #undef BOOST_THREAD_ASYNC_FUNCT
  216. #else
  217. template <class Fp,
  218. class T0 = tuples::null_type, class T1 = tuples::null_type, class T2 = tuples::null_type,
  219. class T3 = tuples::null_type, class T4 = tuples::null_type, class T5 = tuples::null_type,
  220. class T6 = tuples::null_type, class T7 = tuples::null_type, class T8 = tuples::null_type
  221. , class T9 = tuples::null_type
  222. >
  223. class invoker;
  224. template <class Fp,
  225. class T0 , class T1 , class T2 ,
  226. class T3 , class T4 , class T5 ,
  227. class T6 , class T7 , class T8 >
  228. class invoker<Fp, T0, T1, T2, T3, T4, T5, T6, T7, T8>
  229. {
  230. Fp fp_;
  231. T0 v0_;
  232. T1 v1_;
  233. T2 v2_;
  234. T3 v3_;
  235. T4 v4_;
  236. T5 v5_;
  237. T6 v6_;
  238. T7 v7_;
  239. T8 v8_;
  240. //::boost::tuple<Fp, T0, T1, T2, T3, T4, T5, T6, T7, T8> f_;
  241. public:
  242. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  243. typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5, T6, T7, T8)>::type result_type;
  244. BOOST_SYMBOL_VISIBLE
  245. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  246. , BOOST_THREAD_RV_REF(T0) a0
  247. , BOOST_THREAD_RV_REF(T1) a1
  248. , BOOST_THREAD_RV_REF(T2) a2
  249. , BOOST_THREAD_RV_REF(T3) a3
  250. , BOOST_THREAD_RV_REF(T4) a4
  251. , BOOST_THREAD_RV_REF(T5) a5
  252. , BOOST_THREAD_RV_REF(T6) a6
  253. , BOOST_THREAD_RV_REF(T7) a7
  254. , BOOST_THREAD_RV_REF(T8) a8
  255. )
  256. : fp_(boost::move(f))
  257. , v0_(boost::move(a0))
  258. , v1_(boost::move(a1))
  259. , v2_(boost::move(a2))
  260. , v3_(boost::move(a3))
  261. , v4_(boost::move(a4))
  262. , v5_(boost::move(a5))
  263. , v6_(boost::move(a6))
  264. , v7_(boost::move(a7))
  265. , v8_(boost::move(a8))
  266. {}
  267. BOOST_SYMBOL_VISIBLE
  268. invoker(BOOST_THREAD_RV_REF(invoker) f)
  269. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  270. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  271. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  272. , v2_(boost::move(BOOST_THREAD_RV(f).v2_))
  273. , v3_(boost::move(BOOST_THREAD_RV(f).v3_))
  274. , v4_(boost::move(BOOST_THREAD_RV(f).v4_))
  275. , v5_(boost::move(BOOST_THREAD_RV(f).v5_))
  276. , v6_(boost::move(BOOST_THREAD_RV(f).v6_))
  277. , v7_(boost::move(BOOST_THREAD_RV(f).v7_))
  278. , v8_(boost::move(BOOST_THREAD_RV(f).v8_))
  279. {}
  280. result_type operator()()
  281. {
  282. return detail::invoke(boost::move(fp_)
  283. , boost::move(v0_)
  284. , boost::move(v1_)
  285. , boost::move(v2_)
  286. , boost::move(v3_)
  287. , boost::move(v4_)
  288. , boost::move(v5_)
  289. , boost::move(v6_)
  290. , boost::move(v7_)
  291. , boost::move(v8_)
  292. );
  293. }
  294. };
  295. template <class Fp, class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7 >
  296. class invoker<Fp, T0, T1, T2, T3, T4, T5, T6, T7>
  297. {
  298. Fp fp_;
  299. T0 v0_;
  300. T1 v1_;
  301. T2 v2_;
  302. T3 v3_;
  303. T4 v4_;
  304. T5 v5_;
  305. T6 v6_;
  306. T7 v7_;
  307. public:
  308. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  309. typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5, T6, T7)>::type result_type;
  310. BOOST_SYMBOL_VISIBLE
  311. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  312. , BOOST_THREAD_RV_REF(T0) a0
  313. , BOOST_THREAD_RV_REF(T1) a1
  314. , BOOST_THREAD_RV_REF(T2) a2
  315. , BOOST_THREAD_RV_REF(T3) a3
  316. , BOOST_THREAD_RV_REF(T4) a4
  317. , BOOST_THREAD_RV_REF(T5) a5
  318. , BOOST_THREAD_RV_REF(T6) a6
  319. , BOOST_THREAD_RV_REF(T7) a7
  320. )
  321. : fp_(boost::move(f))
  322. , v0_(boost::move(a0))
  323. , v1_(boost::move(a1))
  324. , v2_(boost::move(a2))
  325. , v3_(boost::move(a3))
  326. , v4_(boost::move(a4))
  327. , v5_(boost::move(a5))
  328. , v6_(boost::move(a6))
  329. , v7_(boost::move(a7))
  330. {}
  331. BOOST_SYMBOL_VISIBLE
  332. invoker(BOOST_THREAD_RV_REF(invoker) f)
  333. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  334. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  335. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  336. , v2_(boost::move(BOOST_THREAD_RV(f).v2_))
  337. , v3_(boost::move(BOOST_THREAD_RV(f).v3_))
  338. , v4_(boost::move(BOOST_THREAD_RV(f).v4_))
  339. , v5_(boost::move(BOOST_THREAD_RV(f).v5_))
  340. , v6_(boost::move(BOOST_THREAD_RV(f).v6_))
  341. , v7_(boost::move(BOOST_THREAD_RV(f).v7_))
  342. {}
  343. result_type operator()()
  344. {
  345. return detail::invoke(boost::move(fp_)
  346. , boost::move(v0_)
  347. , boost::move(v1_)
  348. , boost::move(v2_)
  349. , boost::move(v3_)
  350. , boost::move(v4_)
  351. , boost::move(v5_)
  352. , boost::move(v6_)
  353. , boost::move(v7_)
  354. );
  355. }
  356. };
  357. template <class Fp, class T0, class T1, class T2, class T3, class T4, class T5, class T6>
  358. class invoker<Fp, T0, T1, T2, T3, T4, T5, T6>
  359. {
  360. Fp fp_;
  361. T0 v0_;
  362. T1 v1_;
  363. T2 v2_;
  364. T3 v3_;
  365. T4 v4_;
  366. T5 v5_;
  367. T6 v6_;
  368. public:
  369. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  370. typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5, T6)>::type result_type;
  371. BOOST_SYMBOL_VISIBLE
  372. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  373. , BOOST_THREAD_RV_REF(T0) a0
  374. , BOOST_THREAD_RV_REF(T1) a1
  375. , BOOST_THREAD_RV_REF(T2) a2
  376. , BOOST_THREAD_RV_REF(T3) a3
  377. , BOOST_THREAD_RV_REF(T4) a4
  378. , BOOST_THREAD_RV_REF(T5) a5
  379. , BOOST_THREAD_RV_REF(T6) a6
  380. )
  381. : fp_(boost::move(f))
  382. , v0_(boost::move(a0))
  383. , v1_(boost::move(a1))
  384. , v2_(boost::move(a2))
  385. , v3_(boost::move(a3))
  386. , v4_(boost::move(a4))
  387. , v5_(boost::move(a5))
  388. , v6_(boost::move(a6))
  389. {}
  390. BOOST_SYMBOL_VISIBLE
  391. invoker(BOOST_THREAD_RV_REF(invoker) f)
  392. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  393. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  394. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  395. , v2_(boost::move(BOOST_THREAD_RV(f).v2_))
  396. , v3_(boost::move(BOOST_THREAD_RV(f).v3_))
  397. , v4_(boost::move(BOOST_THREAD_RV(f).v4_))
  398. , v5_(boost::move(BOOST_THREAD_RV(f).v5_))
  399. , v6_(boost::move(BOOST_THREAD_RV(f).v6_))
  400. {}
  401. result_type operator()()
  402. {
  403. return detail::invoke(boost::move(fp_)
  404. , boost::move(v0_)
  405. , boost::move(v1_)
  406. , boost::move(v2_)
  407. , boost::move(v3_)
  408. , boost::move(v4_)
  409. , boost::move(v5_)
  410. , boost::move(v6_)
  411. );
  412. }
  413. };
  414. template <class Fp, class T0, class T1, class T2, class T3, class T4, class T5>
  415. class invoker<Fp, T0, T1, T2, T3, T4, T5>
  416. {
  417. Fp fp_;
  418. T0 v0_;
  419. T1 v1_;
  420. T2 v2_;
  421. T3 v3_;
  422. T4 v4_;
  423. T5 v5_;
  424. public:
  425. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  426. typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5)>::type result_type;
  427. BOOST_SYMBOL_VISIBLE
  428. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  429. , BOOST_THREAD_RV_REF(T0) a0
  430. , BOOST_THREAD_RV_REF(T1) a1
  431. , BOOST_THREAD_RV_REF(T2) a2
  432. , BOOST_THREAD_RV_REF(T3) a3
  433. , BOOST_THREAD_RV_REF(T4) a4
  434. , BOOST_THREAD_RV_REF(T5) a5
  435. )
  436. : fp_(boost::move(f))
  437. , v0_(boost::move(a0))
  438. , v1_(boost::move(a1))
  439. , v2_(boost::move(a2))
  440. , v3_(boost::move(a3))
  441. , v4_(boost::move(a4))
  442. , v5_(boost::move(a5))
  443. {}
  444. BOOST_SYMBOL_VISIBLE
  445. invoker(BOOST_THREAD_RV_REF(invoker) f)
  446. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  447. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  448. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  449. , v2_(boost::move(BOOST_THREAD_RV(f).v2_))
  450. , v3_(boost::move(BOOST_THREAD_RV(f).v3_))
  451. , v4_(boost::move(BOOST_THREAD_RV(f).v4_))
  452. , v5_(boost::move(BOOST_THREAD_RV(f).v5_))
  453. {}
  454. result_type operator()()
  455. {
  456. return detail::invoke(boost::move(fp_)
  457. , boost::move(v0_)
  458. , boost::move(v1_)
  459. , boost::move(v2_)
  460. , boost::move(v3_)
  461. , boost::move(v4_)
  462. , boost::move(v5_)
  463. );
  464. }
  465. };
  466. template <class Fp, class T0, class T1, class T2, class T3, class T4>
  467. class invoker<Fp, T0, T1, T2, T3, T4>
  468. {
  469. Fp fp_;
  470. T0 v0_;
  471. T1 v1_;
  472. T2 v2_;
  473. T3 v3_;
  474. T4 v4_;
  475. public:
  476. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  477. typedef typename result_of<Fp(T0, T1, T2, T3, T4)>::type result_type;
  478. BOOST_SYMBOL_VISIBLE
  479. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  480. , BOOST_THREAD_RV_REF(T0) a0
  481. , BOOST_THREAD_RV_REF(T1) a1
  482. , BOOST_THREAD_RV_REF(T2) a2
  483. , BOOST_THREAD_RV_REF(T3) a3
  484. , BOOST_THREAD_RV_REF(T4) a4
  485. )
  486. : fp_(boost::move(f))
  487. , v0_(boost::move(a0))
  488. , v1_(boost::move(a1))
  489. , v2_(boost::move(a2))
  490. , v3_(boost::move(a3))
  491. , v4_(boost::move(a4))
  492. {}
  493. BOOST_SYMBOL_VISIBLE
  494. invoker(BOOST_THREAD_RV_REF(invoker) f)
  495. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  496. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  497. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  498. , v2_(boost::move(BOOST_THREAD_RV(f).v2_))
  499. , v3_(boost::move(BOOST_THREAD_RV(f).v3_))
  500. , v4_(boost::move(BOOST_THREAD_RV(f).v4_))
  501. {}
  502. result_type operator()()
  503. {
  504. return detail::invoke(boost::move(fp_)
  505. , boost::move(v0_)
  506. , boost::move(v1_)
  507. , boost::move(v2_)
  508. , boost::move(v3_)
  509. , boost::move(v4_)
  510. );
  511. }
  512. };
  513. template <class Fp, class T0, class T1, class T2, class T3>
  514. class invoker<Fp, T0, T1, T2, T3>
  515. {
  516. Fp fp_;
  517. T0 v0_;
  518. T1 v1_;
  519. T2 v2_;
  520. T3 v3_;
  521. public:
  522. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  523. typedef typename result_of<Fp(T0, T1, T2, T3)>::type result_type;
  524. BOOST_SYMBOL_VISIBLE
  525. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  526. , BOOST_THREAD_RV_REF(T0) a0
  527. , BOOST_THREAD_RV_REF(T1) a1
  528. , BOOST_THREAD_RV_REF(T2) a2
  529. , BOOST_THREAD_RV_REF(T3) a3
  530. )
  531. : fp_(boost::move(f))
  532. , v0_(boost::move(a0))
  533. , v1_(boost::move(a1))
  534. , v2_(boost::move(a2))
  535. , v3_(boost::move(a3))
  536. {}
  537. BOOST_SYMBOL_VISIBLE
  538. invoker(BOOST_THREAD_RV_REF(invoker) f)
  539. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  540. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  541. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  542. , v2_(boost::move(BOOST_THREAD_RV(f).v2_))
  543. , v3_(boost::move(BOOST_THREAD_RV(f).v3_))
  544. {}
  545. result_type operator()()
  546. {
  547. return detail::invoke(boost::move(fp_)
  548. , boost::move(v0_)
  549. , boost::move(v1_)
  550. , boost::move(v2_)
  551. , boost::move(v3_)
  552. );
  553. }
  554. };
  555. template <class Fp, class T0, class T1, class T2>
  556. class invoker<Fp, T0, T1, T2>
  557. {
  558. Fp fp_;
  559. T0 v0_;
  560. T1 v1_;
  561. T2 v2_;
  562. public:
  563. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  564. typedef typename result_of<Fp(T0, T1, T2)>::type result_type;
  565. BOOST_SYMBOL_VISIBLE
  566. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  567. , BOOST_THREAD_RV_REF(T0) a0
  568. , BOOST_THREAD_RV_REF(T1) a1
  569. , BOOST_THREAD_RV_REF(T2) a2
  570. )
  571. : fp_(boost::move(f))
  572. , v0_(boost::move(a0))
  573. , v1_(boost::move(a1))
  574. , v2_(boost::move(a2))
  575. {}
  576. BOOST_SYMBOL_VISIBLE
  577. invoker(BOOST_THREAD_RV_REF(invoker) f)
  578. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  579. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  580. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  581. , v2_(boost::move(BOOST_THREAD_RV(f).v2_))
  582. {}
  583. result_type operator()()
  584. {
  585. return detail::invoke(boost::move(fp_)
  586. , boost::move(v0_)
  587. , boost::move(v1_)
  588. , boost::move(v2_)
  589. );
  590. }
  591. };
  592. template <class Fp, class T0, class T1>
  593. class invoker<Fp, T0, T1>
  594. {
  595. Fp fp_;
  596. T0 v0_;
  597. T1 v1_;
  598. public:
  599. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  600. typedef typename result_of<Fp(T0, T1)>::type result_type;
  601. BOOST_SYMBOL_VISIBLE
  602. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  603. , BOOST_THREAD_RV_REF(T0) a0
  604. , BOOST_THREAD_RV_REF(T1) a1
  605. )
  606. : fp_(boost::move(f))
  607. , v0_(boost::move(a0))
  608. , v1_(boost::move(a1))
  609. {}
  610. BOOST_SYMBOL_VISIBLE
  611. invoker(BOOST_THREAD_RV_REF(invoker) f)
  612. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  613. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  614. , v1_(boost::move(BOOST_THREAD_RV(f).v1_))
  615. {}
  616. result_type operator()()
  617. {
  618. return detail::invoke(boost::move(fp_)
  619. , boost::move(v0_)
  620. , boost::move(v1_)
  621. );
  622. }
  623. };
  624. template <class Fp, class T0>
  625. class invoker<Fp, T0>
  626. {
  627. Fp fp_;
  628. T0 v0_;
  629. public:
  630. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  631. typedef typename result_of<Fp(T0)>::type result_type;
  632. BOOST_SYMBOL_VISIBLE
  633. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
  634. , BOOST_THREAD_RV_REF(T0) a0
  635. )
  636. : fp_(boost::move(f))
  637. , v0_(boost::move(a0))
  638. {}
  639. BOOST_SYMBOL_VISIBLE
  640. invoker(BOOST_THREAD_RV_REF(invoker) f)
  641. : fp_(boost::move(BOOST_THREAD_RV(f).fp))
  642. , v0_(boost::move(BOOST_THREAD_RV(f).v0_))
  643. {}
  644. result_type operator()()
  645. {
  646. return detail::invoke(boost::move(fp_)
  647. , boost::move(v0_)
  648. );
  649. }
  650. };
  651. template <class Fp>
  652. class invoker<Fp>
  653. {
  654. Fp fp_;
  655. public:
  656. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  657. typedef typename result_of<Fp()>::type result_type;
  658. BOOST_SYMBOL_VISIBLE
  659. explicit invoker(BOOST_THREAD_FWD_REF(Fp) f)
  660. : fp_(boost::move(f))
  661. {}
  662. BOOST_SYMBOL_VISIBLE
  663. invoker(BOOST_THREAD_RV_REF(invoker) f)
  664. : fp_(boost::move(f.fp_))
  665. {}
  666. result_type operator()()
  667. {
  668. return fp_();
  669. }
  670. };
  671. template <class R>
  672. class invoker<R(*)()>
  673. {
  674. typedef R(*Fp)();
  675. Fp fp_;
  676. public:
  677. BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
  678. typedef typename result_of<Fp()>::type result_type;
  679. BOOST_SYMBOL_VISIBLE
  680. explicit invoker(Fp f)
  681. : fp_(f)
  682. {}
  683. BOOST_SYMBOL_VISIBLE
  684. invoker(BOOST_THREAD_RV_REF(invoker) f)
  685. : fp_(f.fp_)
  686. {}
  687. result_type operator()()
  688. {
  689. return fp_();
  690. }
  691. };
  692. #endif
  693. #endif
  694. }
  695. }
  696. #include <boost/thread/detail/variadic_footer.hpp>
  697. #endif // header