1 // (C) Copyright 2009 Anthony Williams
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #include <boost/thread/thread_only.hpp>
8 #include <boost/thread/mutex.hpp>
9 #include <boost/thread/condition.hpp>
10 #include <boost/thread/future.hpp>
15 #define BOOST_TEST_MODULE Boost.Threads: thread exit test suite
17 #include <boost/test/unit_test.hpp>
19 boost::thread::id exit_func_thread_id
;
23 exit_func_thread_id
=boost::this_thread::get_id();
28 boost::this_thread::at_thread_exit(exit_func
);
29 BOOST_CHECK(exit_func_thread_id
!=boost::this_thread::get_id());
32 BOOST_AUTO_TEST_CASE(test_thread_exit_func_runs_when_thread_exits
)
34 exit_func_thread_id
=boost::thread::id();
35 boost::thread
t(&tf1
);
36 boost::thread::id
const t_id
=t
.get_id();
38 BOOST_CHECK(exit_func_thread_id
==t_id
);
45 exit_func_thread_id
=boost::this_thread::get_id();
51 boost::this_thread::at_thread_exit(fo());
52 BOOST_CHECK(exit_func_thread_id
!=boost::this_thread::get_id());
56 BOOST_AUTO_TEST_CASE(test_can_use_function_object_for_exit_func
)
58 exit_func_thread_id
=boost::thread::id();
60 boost::thread::id
const t_id
=t
.get_id();
62 BOOST_CHECK(exit_func_thread_id
==t_id
);