Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-06-30 07:10:40


Michael Glassford wrote:
>
> Finally, to take two more realistic use cases:
>
> void f(read_write_mutex m)
> {
> read_write_mutex::write_lock w(m);
>
> //...
>
> read_write_mutex::read_lock r(w); //lock promotion
>
> //...
> }
>
> And:
>
> void f(read_write_mutex m)
> {
> read_write_mutex::write_lock r(m);
>
> //...
>
> read_write_mutex::read_lock w(r); //lock demotion
>
> //...
> }
>
> The second lock does unnecessary work in demoting/promoting the lock
> for the first lock, which then immediately unlocks it.

This is a very good point, since in the second example the unnecessary
promotion would block. This seems to suggest that read_write_lock is
necessary in such a scenario.


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