]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | //---------------------------------------------------------------------------// |
2 | // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com> | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0 | |
5 | // See accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt | |
7 | // | |
8 | // See http://boostorg.github.com/compute for more information. | |
9 | //---------------------------------------------------------------------------// | |
10 | ||
11 | #ifndef BOOST_COMPUTE_ASYNC_WAIT_HPP | |
12 | #define BOOST_COMPUTE_ASYNC_WAIT_HPP | |
13 | ||
14 | #include <boost/compute/config.hpp> | |
15 | #include <boost/compute/utility/wait_list.hpp> | |
16 | ||
17 | namespace boost { | |
18 | namespace compute { | |
19 | namespace detail { | |
20 | ||
21 | #ifndef BOOST_COMPUTE_NO_VARIADIC_TEMPLATES | |
22 | template<class Event> | |
23 | inline void insert_events_variadic(wait_list &l, Event&& event) | |
24 | { | |
25 | l.insert(std::forward<Event>(event)); | |
26 | } | |
27 | ||
28 | template<class Event, class... Rest> | |
29 | inline void insert_events_variadic(wait_list &l, Event&& event, Rest&&... rest) | |
30 | { | |
31 | l.insert(std::forward<Event>(event)); | |
32 | ||
33 | insert_events_variadic(l, std::forward<Rest>(rest)...); | |
34 | } | |
35 | #endif // BOOST_COMPUTE_NO_VARIADIC_TEMPLATES | |
36 | ||
37 | } // end detail namespace | |
38 | ||
39 | #ifndef BOOST_COMPUTE_NO_VARIADIC_TEMPLATES | |
40 | /// Blocks until all events have completed. Events can either be \ref event | |
41 | /// objects or \ref future "future<T>" objects. | |
42 | /// | |
43 | /// \see event, wait_list | |
44 | template<class... Events> | |
45 | inline void wait_for_all(Events&&... events) | |
46 | { | |
47 | wait_list l; | |
48 | detail::insert_events_variadic(l, std::forward<Events>(events)...); | |
49 | l.wait(); | |
50 | } | |
51 | #endif // BOOST_COMPUTE_NO_VARIADIC_TEMPLATES | |
52 | ||
53 | } // end compute namespace | |
54 | } // end boost namespace | |
55 | ||
56 | #endif // BOOST_COMPUTE_ASYNC_WAIT_HPP |