test_4521.cpp 904 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2010 Vicente Botet
  2. //
  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)
  5. #define BOOST_THREAD_VERSION 2
  6. #include <boost/thread/thread_only.hpp>
  7. #include <boost/thread/future.hpp>
  8. int calculate_the_answer_to_life_the_universe_and_everything()
  9. {
  10. return 42;
  11. }
  12. int main() {
  13. boost::packaged_task<int> pt(calculate_the_answer_to_life_the_universe_and_everything);
  14. //boost::unique_future<int> fi = BOOST_THREAD_MAKE_RV_REF(pt.get_future());
  15. boost::unique_future<int> fi((BOOST_THREAD_MAKE_RV_REF(pt.get_future())));
  16. boost::thread task(boost::move(pt)); // launch task on a thread
  17. fi.wait(); // wait for it to finish
  18. //assert(fi.is_ready());
  19. //assert(fi.has_value());
  20. //assert(!fi.has_exception());
  21. //assert(fi.get_state()==boost::future_state::ready);
  22. //assert(fi.get()==42);
  23. }