2
0
mirror of https://github.com/boostorg/thread.git synced 2026-01-27 07:22:11 +00:00
Files
thread/test/test_7720.cpp
Vicente J. Botet Escriba dc352450ca Thread: added load test for shared_mutex.
[SVN r82925]
2013-02-16 15:11:19 +00:00

50 lines
715 B
C++

// Copyright (C) 2013 Vicente Botet
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
////////////////////////////////////////////
#include <boost/thread/thread.hpp>
using namespace boost;
shared_mutex mtx;
void f()
{
while (true)
{
upgrade_lock<shared_mutex> lock(mtx);
}
}
void g()
{
while (true)
{
shared_lock<shared_mutex> lock(mtx);
}
}
void h()
{
while (true)
{
unique_lock<shared_mutex> lock(mtx);
}
}
int main()
{
thread t0(f);
thread t1(g);
thread t2(h);
t0.join();
t1.join();
t2.join();
return 0;
}