Boost logo

Threads-Devel :

From: Anthony Williams (anthony_at_[hidden])
Date: 2007-12-06 03:02:43

Quoting Frank Mori Hess <frank.hess_at_[hidden]>:

> On Tuesday 27 November 2007 03:06 am, Anthony Williams wrote:
>> The new trunk code provides two condition variable types:
>> condition_variable and condition_variable_any.
>> condition_variable works with unique_lock<mutex> ONLY, and the function
>> signatures are explicit about that. condition_variable_any will work with
>> anything that supports unlock() and lock().
> Is it possible to make condition_variable_any work with recursive
> mutexes? It
> seems like an additional interface on the lock would be required, since a
> recursive mutex may still be locked by the current thread even after calling
> unlock().

I think that would be dangerous. If you don't know how many times
you've locked the recursive mutex when you call wait() (in order to
unlock all but one prior to the call), then you might be unlocking the
mutex when a layer above you is expecting it to still be locked and
has incomplete changes that are protected by the lock.


Anthony Williams
Just Software Solutions Ltd -
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Threads-Devel list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at