7 #include <boost/thread/mutex.hpp>
8 #include <boost/thread/thread.hpp>
10 #define BOOST_AUTO_TEST_MAIN
11 #include <boost/test/auto_unit_test.hpp>
13 using namespace boost::unit_test;
15 boost::mutex io_mutex;
23 void operator() (void) {
24 for (int i=0; i < 100; ++i)
34 boost::mutex::scoped_lock scoped_lock(io_mutex);
35 std::cout << "Worker " << m_nr
36 << " session.id() " << m_id << std::endl;
46 BOOST_AUTO_TEST_CASE( testsession2 )
52 const int num_threads = 100;
53 boost::thread_group thrds;
56 for (int i=0; i < num_threads; ++i)
58 // Notice that each Worker has it's own session object!
60 thrds.add_thread(new boost::thread(w));
65 BOOST_CHECK (session.id() == 10001);
68 catch (std::exception &e) {
69 std::cout << e.what() << "\n";
80 * indent-tabs-mode: nil
82 * vim: shiftwidth=4 tabstop=8 expandtab