Boost logo

Boost :

From: Matthew Vogt (mvogt_at_[hidden])
Date: 2004-07-05 22:29:15

Bruno Martínez Aguerre <br1 <at>> writes:

> What about a latent_write_lock?
> It's semantics would be to block on contruction until it only shares the
> mutex with read_locks. A write_lock could be contructed from a
> latent_write_lock and this would always work, because another
> latent_write_lock would still be blocked in it's constructor. This kind
> of lock would be useful for situations in which you have to read a
> structure to know if you have to write on it.
> Bruno Martinez

Interesting, this divides read locks into promotable and non-promotable

If you have a design where a lot of threads take concurrent read locks, and the
case of promotion is rare, then having them all use latent_write_locks will
unnecessarily serialise them. Allowing promotion failure instead would only
affect rare cases of promotion contention.

If you have a case where promotion is common, then you probably won't gain much
over simply using write locks, will you?

If you can mix a number of read-only locks with a small number of
latent_write_locks for which promotion is uncommon, then you have an optimum


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