3 #include <boost/thread/mutex.hpp>
4 #include <boost/thread/thread.hpp>
6 #define BOOST_AUTO_TEST_MAIN
7 #include <boost/test/auto_unit_test.hpp>
15 counter() : count(0) { }
18 boost::mutex::scoped_lock scoped_lock(mutex);
32 void operator() (void) {
40 BOOST_AUTO_TEST_CASE( thread_group )
44 const int num_threads = 4;
45 boost::thread_group thrds;
47 for (int i=0; i < num_threads; ++i)
50 thrds.add_thread(new boost::thread(w));
58 BOOST_CHECK(c.increment() == 5);
62 BOOST_AUTO_TEST_CASE( thread_list )
66 const int num_threads = 4;
67 std::list<boost::thread *> thread_list;
69 for (int i=0; i < num_threads; ++i)
72 thread_list.push_back(new boost::thread(w));
74 std::list<boost::thread *>::iterator it;
75 for (it = thread_list.begin(); it != thread_list.end(); it++)
86 BOOST_CHECK(c.increment() == 10);
94 * indent-tabs-mode: nil
96 * vim: shiftwidth=4 tabstop=8 expandtab