1 /* $Id: test_session2.cpp,v 1.10 2007-05-09 21:23:09 adam Exp $
2 Copyright (c) 2005-2007, Index Data.
4 This file is part of Metaproxy.
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "session.hpp"
28 #include <boost/thread/mutex.hpp>
29 #include <boost/thread/thread.hpp>
31 #define BOOST_AUTO_TEST_MAIN
32 #include <boost/test/auto_unit_test.hpp>
34 using namespace boost::unit_test;
35 namespace mp = metaproxy_1;
37 boost::mutex io_mutex;
45 void operator() (void) {
46 for (int i=0; i < 100; ++i)
56 boost::mutex::scoped_lock scoped_lock(io_mutex);
57 std::cout << "Worker " << m_nr
58 << " session.id() " << m_id << std::endl;
68 BOOST_AUTO_UNIT_TEST( testsession2 )
74 const int num_threads = 100;
75 boost::thread_group thrds;
78 for (int i=0; i < num_threads; ++i)
80 // Notice that each Worker has it's own session object!
82 thrds.add_thread(new boost::thread(w));
87 BOOST_CHECK (session.id() == 10001);
90 catch (std::exception &e) {
91 std::cout << e.what() << "\n";
102 * indent-tabs-mode: nil
103 * c-file-style: "stroustrup"
105 * vim: shiftwidth=4 tabstop=8 expandtab