test_thread_return_local.cpp 843 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2009 Anthony Williams
  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_USES_MOVE
  6. #define BOOST_TEST_MODULE Boost.Threads: thread return local test suite
  7. #include <boost/thread/thread_only.hpp>
  8. #include <boost/test/unit_test.hpp>
  9. void do_nothing(boost::thread::id* my_id)
  10. {
  11. *my_id=boost::this_thread::get_id();
  12. }
  13. boost::thread make_thread_return_local(boost::thread::id* the_id)
  14. {
  15. boost::thread t(do_nothing,the_id);
  16. return boost::move(t);
  17. }
  18. BOOST_AUTO_TEST_CASE(test_move_from_function_return_local)
  19. {
  20. boost::thread::id the_id;
  21. boost::thread x=make_thread_return_local(&the_id);
  22. boost::thread::id x_id=x.get_id();
  23. x.join();
  24. BOOST_CHECK_EQUAL(the_id,x_id);
  25. }