1 /* $Id: test_boost_threads.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $
2 Copyright (c) 2005-2006, Index Data.
8 #include <boost/thread/mutex.hpp>
9 #include <boost/thread/thread.hpp>
11 #define BOOST_AUTO_TEST_MAIN
12 #include <boost/test/auto_unit_test.hpp>
20 counter() : count(0) { }
23 boost::mutex::scoped_lock scoped_lock(mutex);
37 void operator() (void) {
45 BOOST_AUTO_UNIT_TEST( thread_group )
49 const int num_threads = 4;
50 boost::thread_group thrds;
52 for (int i=0; i < num_threads; ++i)
55 thrds.add_thread(new boost::thread(w));
63 BOOST_CHECK(c.increment() == 5);
67 BOOST_AUTO_UNIT_TEST( thread_list )
71 const int num_threads = 4;
72 std::list<boost::thread *> thread_list;
74 for (int i=0; i < num_threads; ++i)
77 thread_list.push_back(new boost::thread(w));
79 std::list<boost::thread *>::iterator it;
80 for (it = thread_list.begin(); it != thread_list.end(); it++)
91 BOOST_CHECK(c.increment() == 10);
99 * indent-tabs-mode: nil
100 * c-file-style: "stroustrup"
102 * vim: shiftwidth=4 tabstop=8 expandtab