|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-08-25 10:59:31
Yuval Ronen:
> Peter Dimov wrote:
>> 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.
>
> Hinting the user to lock a mutex by accepting a lock is getting too
> psychological for my taste. If it was enforced by the compiler, then
> maybe, but since the compiler can't...
The hint isn't particularly subtle. You have to pass a lock, and this _is_
enforced by the compiler. The rest of the enforcement (that the lock 'owns'
the correct mutex) is necessarily postponed to run time; we simply can't do
better than that.
I'm really not sure how you propose to achieve the same level of encouraging
and enforcing correct use with a wait function that doesn't take a lock
argument, and I'm also unsure what specific problems with requiring a lock
argument are you trying to solve.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk