1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_ASYNC_FUTURE_HPP
12 #define BOOST_COMPUTE_ASYNC_FUTURE_HPP
14 #include <boost/compute/event.hpp>
20 /// \brief Holds the result of an asynchronous computation.
22 /// \see event, wait_list
32 future(const T &result, const event &event)
38 future(const future<T> &other)
39 : m_result(other.m_result),
40 m_event(other.m_event)
44 future& operator=(const future<T> &other)
47 m_result = other.m_result;
48 m_event = other.m_event;
58 /// Returns the result of the computation. This will block until
59 /// the result is ready.
67 /// Returns \c true if the future is valid.
73 /// Blocks until the computation is complete.
79 /// Returns the underlying event object.
80 event get_event() const
101 future(const future<T> &other)
102 : m_event(other.get_event())
106 explicit future(const event &event)
112 future<void> &operator=(const future<T> &other)
114 m_event = other.get_event();
119 future<void> &operator=(const future<void> &other)
122 m_event = other.m_event;
147 event get_event() const
157 template<class Result>
158 inline future<Result> make_future(const Result &result, const event &event)
160 return future<Result>(result, event);
163 } // end compute namespace
164 } // end boost namespace
166 #endif // BOOST_COMPUTE_ASYNC_FUTURE_HPP