1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2011 Index Data
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <boost/thread/mutex.hpp>
21 #include <boost/thread/thread.hpp>
23 #define BOOST_AUTO_TEST_MAIN
24 #define BOOST_TEST_DYN_LINK
25 #include <boost/test/auto_unit_test.hpp>
33 counter() : count(0) { }
36 boost::mutex::scoped_lock scoped_lock(mutex);
50 void operator() (void) {
58 BOOST_AUTO_TEST_CASE( thread_group )
62 const int num_threads = 4;
63 boost::thread_group thrds;
65 for (int i=0; i < num_threads; ++i)
68 thrds.add_thread(new boost::thread(w));
76 BOOST_CHECK(c.increment() == 5);
80 BOOST_AUTO_TEST_CASE( thread_list )
84 const int num_threads = 4;
85 std::list<boost::thread *> thread_list;
87 for (int i=0; i < num_threads; ++i)
90 thread_list.push_back(new boost::thread(w));
92 std::list<boost::thread *>::iterator it;
93 for (it = thread_list.begin(); it != thread_list.end(); it++)
104 BOOST_CHECK(c.increment() == 10);
112 * c-file-style: "Stroustrup"
113 * indent-tabs-mode: nil
115 * vim: shiftwidth=4 tabstop=8 expandtab