1 /* $Id: test_session2.cpp,v 1.6 2005-12-02 12:21:07 adam Exp $
2 Copyright (c) 2005, Index Data.
12 #include <boost/thread/mutex.hpp>
13 #include <boost/thread/thread.hpp>
15 #define BOOST_AUTO_TEST_MAIN
16 #include <boost/test/auto_unit_test.hpp>
18 using namespace boost::unit_test;
20 boost::mutex io_mutex;
28 void operator() (void) {
29 for (int i=0; i < 100; ++i)
39 boost::mutex::scoped_lock scoped_lock(io_mutex);
40 std::cout << "Worker " << m_nr
41 << " session.id() " << m_id << std::endl;
51 BOOST_AUTO_UNIT_TEST( testsession2 )
57 const int num_threads = 100;
58 boost::thread_group thrds;
61 for (int i=0; i < num_threads; ++i)
63 // Notice that each Worker has it's own session object!
65 thrds.add_thread(new boost::thread(w));
70 BOOST_CHECK (session.id() == 10001);
73 catch (std::exception &e) {
74 std::cout << e.what() << "\n";
85 * indent-tabs-mode: nil
86 * c-file-style: "stroustrup"
88 * vim: shiftwidth=4 tabstop=8 expandtab