Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-06-29 12:00:47


Michael Glassford wrote:
>
> Also, you could end up with some interesting situations like this:
>
> void f(read_write_mutex m)
> {
> read_write_mutex::read_lock r(m);
> if (...)
> {
> read_write_mutex::write_lock w(r); //lock promotion
> //...
> }
> //Point A
> }
>
> The most obvious implementation of promotion would be for the write lock
> to unlock the read lock if promotion succeeded, but leave it locked if
> promotion failed. But in the above code, this would mean that if
> promotion succeeds, neither lock will be locked at "Point A"; however
> if promotion fails, r will still be read-locked at point A.

Not necessarily, ~write_lock can (should) demote the lock back to read (or
whatever the initial condition of r was).


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