2 #include <boost/thread/mutex.hpp>
3 #include <boost/thread/thread.hpp>
5 #define BOOST_AUTO_TEST_MAIN
6 #include <boost/test/auto_unit_test.hpp>
14 counter() : count(0) { }
17 boost::mutex::scoped_lock scoped_lock(mutex);
31 void operator() (void) {
39 BOOST_AUTO_TEST_CASE( thread_group )
43 const int num_threads = 4;
44 boost::thread_group thrds;
46 for (int i=0; i < num_threads; ++i)
49 thrds.add_thread(new boost::thread(w));
57 BOOST_CHECK(c.increment() == 5);
61 BOOST_AUTO_TEST_CASE( thread_list )
65 const int num_threads = 4;
66 std::list<boost::thread *> thread_list;
68 for (int i=0; i < num_threads; ++i)
71 thread_list.push_back(new boost::thread(w));
73 std::list<boost::thread *>::iterator it;
74 for (it = thread_list.begin(); it != thread_list.end(); it++)
85 BOOST_CHECK(c.increment() == 10);
93 * indent-tabs-mode: nil
95 * vim: shiftwidth=4 tabstop=8 expandtab