3 #include <boost/thread/mutex.hpp>
4 #include <boost/function.hpp>
5 #include <boost/optional.hpp>
13 auto flatten(std::future<T>&& f) -> std::future<typename std::decay<decltype(f.get().get())>::type>
15 auto shared_f = f.share();
16 return std::async(std::launch::deferred, [=]() mutable -> typename std::decay<decltype(f.get().get())>::type
18 return shared_f.get().get();
23 bool is_ready(const F& future)
25 return future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
29 * Wrap a value in a future with an already known result.
31 * Useful when the result of an operation is already known at the time of
34 * @param value The r-value to wrap.
36 * @return The future with the result set.
39 std::future<R> make_ready_future(R&& value)
45 return p.get_future();
48 static std::future<void> make_ready_future()
54 return p.get_future();