]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/pool/test/test_threading.cpp
1 /* Copyright (C) 2011 John Maddock
3 * Use, modification and distribution is subject to the
4 * Boost Software License, Version 1.0. (See accompanying
5 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/pool/pool_alloc.hpp>
10 #include <boost/thread.hpp>
11 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1400)
13 #pragma warning(disable:4244)
15 #include <boost/random/mersenne_twister.hpp>
16 #include <boost/random/uniform_int_distribution.hpp>
17 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1400)
23 boost::random::mt19937 gen
;
24 boost::random::uniform_int_distribution
<> dist(-10, 10);
25 std::list
<int, boost::fast_pool_allocator
<int> > l
;
27 for(int i
= 0; i
< 100; ++i
)
30 for(int i
= 0; i
< 100000; ++i
)
35 while(val
&& l
.size())
54 std::list
<boost::shared_ptr
<boost::thread
> > threads
;
55 for(int i
= 0; i
< 10; ++i
)
58 threads
.push_back(boost::shared_ptr
<boost::thread
>(new boost::thread(&run_tests
)));
60 catch(const std::exception
& e
)
62 std::cerr
<< "<note>Thread creation failed with message: " << e
.what() << "</note>" << std::endl
;
65 std::list
<boost::shared_ptr
<boost::thread
> >::const_iterator
a(threads
.begin()), b(threads
.end());