1 // Copyright (C) 2010 Vicente Botet
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/thread/shared_mutex.hpp>
7 #include <boost/thread/locks.hpp>
9 // Including this will cause ambiguous errors in boost::move
10 #include <boost/unordered_map.hpp>
12 using namespace boost;
14 typedef upgrade_lock<shared_mutex> auto_upgrade_lock;
15 typedef upgrade_to_unique_lock<shared_mutex> auto_upgrade_unique_lock;
17 void testUpgrade(void)
20 auto_upgrade_lock lock(mtx);
21 // Do some read-only stuff
23 auto_upgrade_unique_lock writeLock(lock);
24 // Do some write-only stuff with the upgraded lock