Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2022-06-17 18:23:08


Dear Experts,

boost::upgrade_mutex m;

void f() {
   boost::upgrade_lock l(m);
   // read shared state
   g();
}

void g() {
   // precondition: upgrade lock held.
   boost::upgrade_to_unique_lock l(m);
   // write shared state
}

But that's not how it works. The upgrade_to_unique_lock
takes the upgrade_lock as its ctor parameter, not the mutex.

Is there a good reason for that? I think all that
upgrade_to_unique_lock needs to do is to call
m.unlock_upgrade_and_lock() in its ctor and
m.unlock_and_lock_upgrade() in its dotr, i.e. it doesn't
need to access any state in the upgrade_lock.

Am I missing something?

Regards, Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk