1 // Copyright (C) 2010 Vicente Botet
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)
6 #define BOOST_THREAD_VERSION 2
8 #include <boost/thread/thread_only.hpp>
9 #include <boost/thread/future.hpp>
11 int calculate_the_answer_to_life_the_universe_and_everything()
17 boost::packaged_task<int> pt(calculate_the_answer_to_life_the_universe_and_everything);
19 //boost::unique_future<int> fi = BOOST_THREAD_MAKE_RV_REF(pt.get_future());
20 boost::unique_future<int> fi((BOOST_THREAD_MAKE_RV_REF(pt.get_future())));
22 boost::thread task(boost::move(pt)); // launch task on a thread
24 fi.wait(); // wait for it to finish
26 //assert(fi.is_ready());
27 //assert(fi.has_value());
28 //assert(!fi.has_exception());
29 //assert(fi.get_state()==boost::future_state::ready);
30 //assert(fi.get()==42);