Chris@102
|
1 // (C) Copyright 2008-10 Anthony Williams
|
Chris@102
|
2 // (C) Copyright 2011-2015 Vicente J. Botet Escriba
|
Chris@102
|
3 //
|
Chris@102
|
4 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@102
|
5 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
7
|
Chris@102
|
8 #ifndef BOOST_THREAD_FUTURES_WAIT_FOR_ALL_HPP
|
Chris@102
|
9 #define BOOST_THREAD_FUTURES_WAIT_FOR_ALL_HPP
|
Chris@102
|
10
|
Chris@102
|
11 #include <boost/thread/detail/config.hpp>
|
Chris@102
|
12 #include <boost/thread/futures/is_future_type.hpp>
|
Chris@102
|
13
|
Chris@102
|
14 #include <boost/core/enable_if.hpp>
|
Chris@102
|
15
|
Chris@102
|
16 namespace boost
|
Chris@102
|
17 {
|
Chris@102
|
18 template<typename Iterator>
|
Chris@102
|
19 typename boost::disable_if<is_future_type<Iterator>,void>::type wait_for_all(Iterator begin,Iterator end)
|
Chris@102
|
20 {
|
Chris@102
|
21 for(Iterator current=begin;current!=end;++current)
|
Chris@102
|
22 {
|
Chris@102
|
23 current->wait();
|
Chris@102
|
24 }
|
Chris@102
|
25 }
|
Chris@102
|
26
|
Chris@102
|
27 #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
|
Chris@102
|
28 template<typename F1,typename F2>
|
Chris@102
|
29 typename boost::enable_if<is_future_type<F1>,void>::type wait_for_all(F1& f1,F2& f2)
|
Chris@102
|
30 {
|
Chris@102
|
31 f1.wait();
|
Chris@102
|
32 f2.wait();
|
Chris@102
|
33 }
|
Chris@102
|
34
|
Chris@102
|
35 template<typename F1,typename F2,typename F3>
|
Chris@102
|
36 void wait_for_all(F1& f1,F2& f2,F3& f3)
|
Chris@102
|
37 {
|
Chris@102
|
38 f1.wait();
|
Chris@102
|
39 f2.wait();
|
Chris@102
|
40 f3.wait();
|
Chris@102
|
41 }
|
Chris@102
|
42
|
Chris@102
|
43 template<typename F1,typename F2,typename F3,typename F4>
|
Chris@102
|
44 void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4)
|
Chris@102
|
45 {
|
Chris@102
|
46 f1.wait();
|
Chris@102
|
47 f2.wait();
|
Chris@102
|
48 f3.wait();
|
Chris@102
|
49 f4.wait();
|
Chris@102
|
50 }
|
Chris@102
|
51
|
Chris@102
|
52 template<typename F1,typename F2,typename F3,typename F4,typename F5>
|
Chris@102
|
53 void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5)
|
Chris@102
|
54 {
|
Chris@102
|
55 f1.wait();
|
Chris@102
|
56 f2.wait();
|
Chris@102
|
57 f3.wait();
|
Chris@102
|
58 f4.wait();
|
Chris@102
|
59 f5.wait();
|
Chris@102
|
60 }
|
Chris@102
|
61 #else
|
Chris@102
|
62 template<typename F1, typename... Fs>
|
Chris@102
|
63 void wait_for_all(F1& f1, Fs&... fs)
|
Chris@102
|
64 {
|
Chris@102
|
65 bool dummy[] = { (f1.wait(), true), (fs.wait(), true)... };
|
Chris@102
|
66
|
Chris@102
|
67 // prevent unused parameter warning
|
Chris@102
|
68 (void) dummy;
|
Chris@102
|
69 }
|
Chris@102
|
70 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)}
|
Chris@102
|
71
|
Chris@102
|
72 }
|
Chris@102
|
73
|
Chris@102
|
74 #endif // header
|