From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-08-24 21:30:54
Yuval Ronen wrote:
> Peter Dimov wrote:
>> Howard Hinnant wrote:
>>> Or should condition::wait() not take any parameters, or take only
>>> mutexes, making the issue moot?
>> I think that we ought to keep the lock argument, even if we end up not
>> it for anything except debug checks. It helps people avoid accidental
>> to 'wait' without locking the mutex first.
> If, by "It helps people avoid accidental...", you mean "at compile
> time", then it's not always detected in compile time, because the
> existence of a lock doesn't mean a mutex is locked (e.g. unique_lock).
I meant "helps people avoid accidental mistakes at the time they're writing
the code". The function encourages correct use by asking for a lock,
implying that the mutex needs to be locked first.
There was an article by Andrei Alexandrescu somewhere on informit.com where
he advocated a similar pattern: the functions that assume that a mutex has
been locked should take a lock argument.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk