So I had some shared_mutex and done this:
boost::upgrade_lock<boost::shared_mutex> lock(f->mutex);
boost::upgrade_to_unique_lock<boost::shared_mutex> uniqueLock(lock);
now I want to “unlock it” or at least downgrade it to something like:
boost::shared_lock<boost::shared_mutex> lock_r(f->mutex);
How to do such thing? Is it possible?
If you let the
upgrade_to_unique_lockgo out of scope, it will automatically downgrade back to upgrade ownership.For example
Edit: One other thing. If a given function only requires exclusive locks, you can use
boost::unique_lockand lock uniquely, without going through both theupgradeandupgrade_to_uniquelocks.