mirror of
https://github.com/boostorg/thread.git
synced 2026-01-24 18:32:32 +00:00
26 lines
568 B
C++
26 lines
568 B
C++
#include <boost/thread/shared_mutex.hpp>
|
|
#include <boost/thread/locks.hpp>
|
|
|
|
// Including this will cause ambiguous errors in boost::move
|
|
#include <boost/unordered_map.hpp>
|
|
|
|
using namespace boost;
|
|
|
|
typedef upgrade_lock<shared_mutex> auto_upgrade_lock;
|
|
typedef upgrade_to_unique_lock<shared_mutex> auto_upgrade_unique_lock;
|
|
|
|
void testUpgrade(void)
|
|
{
|
|
shared_mutex mtx;
|
|
auto_upgrade_lock lock(mtx);
|
|
// Do some read-only stuff
|
|
|
|
auto_upgrade_unique_lock writeLock(lock);
|
|
// Do some write-only stuff with the upgraded lock
|
|
}
|
|
|
|
int main()
|
|
{
|
|
testUpgrade();
|
|
return 0;
|
|
} |