From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2007-08-26 17:47:31
Howard Hinnant wrote:
> At this point I'm really leaning towards getting back to basics:
<snip options for class condition>
It seems I wasn't very successful in convincing, so I'll try one last
time. I strongly recommend you seriously consider
template <class Mutex>
explicit condition(Mutex &); // or Mutex*
void set_mutex(Mutex &); // or Mutex*
// more wait() overloads with predicate and timeout
// and of course the notify functions
I'll repeat the advantages I see for this approach:
1. It can work for any user-defined mutex.
2. Yet it can be specialized for better sizeof for std::mutex.
3. It can be made to check for errors (not assigning a mutex or not
locking the mutex) when calling wait().
4. Yet it can be made to be as-fast-as-possible.
5. It can dynamically switch the mutex which the condition works for
(for the rare cases when it is needed).
6. It allows easily using the condition in a deeper function than the
one that locked the mutex.
7. It doesn't force using locks (which I see as a plus, because there's
a reason we brought mutex back his lock/unlock).
8. It doesn't introduce an unprecedented technique of "encouraging"
users to lock (by passing a lock to a function). A technique which I
find to be cumbersome and misleading (because it works only partially).
Unfortunately I have to leave in an hour for two weeks, so I'm out of
this discussion for now, but please don't dismiss this idea without
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk