Boost logo

Boost Users :

Subject: [Boost-users] upgrading lock
From: Igor R (boost.lists_at_[hidden])
Date: 2013-02-21 08:05:07


Hello,

Just wanted to be sure that I'm doing this correctly.

typedef boost::upgrade_lock<boost::shared_mutex> upgrade_lock;
typedef boost::upgrade_to_unique_lock<boost::shared_mutex>
upgrade_to_unique_lock;

upgrade_lock readLock(mutex_);
// accessing shared resources in read-only mode
//...
upgrade_to_unique_lock writeLock(readLock);
// modifying shared resources

Is the above correct? In particular, upgrade_lock acquires "read" lock
in raii style (similarly to shared_lock), right?

Thanks.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net