Boost logo

Boost :

From: Matthew Vogt (mvogt_at_[hidden])
Date: 2004-07-06 17:43:24

Peter Dimov <pdimov <at>> writes:

> The read lock is pointless in this case. The idea is that get_balance() is
> slow, so we want to perform it under only a read lock, to avoid stalling
> readers unnecessarily. However your code performs it again under the write
> lock anyway. It's much simpler to just do the whole operation under a write
> lock.
> These examples are mostly what led me to believe that promotion isn't very
> useful. But I may be missing an important use case.

Promotion is not necessary, but it can improve peformance - if you have a case
where you must perform some work before knowing whether you need to perform
an update, then the cost of performing that work with exclusive access may be
prohibitive. This cost must be balanced against the potential cost of having
to perform the same work a second time in the case the promotion fails.

I would suppose that promotion is most suitable to a case where there are many
readers, each of which has a low probability of having to do an update. I
can't immediately think of an example that would present such a case, however,
so it may be more theoretical than practical.


Boost list run by bdawes at, gregod at, cpdaniel at, john at