From: David Abrahams (dave_at_[hidden])
Date: 2002-10-18 10:19:43
"Peter Dimov" <pdimov_at_[hidden]> writes:
> Of historical interest: from my review of the Threads library, 31.08.2001:
> "The mutex is missing one bit of functionality that I consider critical.
> two threads need to lock two (or more) mutexes, the lock order must be the
> same to avoid deadlocks. No support is provided for this operation. Possible
> alternatives are
> template<class M1, class M2, ...> class scoped_multiple_lock
> scoped_multiple_lock(M1 &, M2 &, ...);
> template<class M1, class M2, ...> class mutex_tuple
> typedef ... scoped_lock;
> mutex_tuple(M1 &, M2 &, ...);
> "I'd like to see
> template<class M, class P, class F> void wait(M & m, P p, F f)
> typename M::scoped_lock lock(m);
> while(!p()) this->wait(lock);
> added, for people that want to go the extra mile (when someone bothers to
> define a predicate to use the wait(l, p) form, (s)he would probably define
> an action object, too.)"
FWIW, I support all of Peter's points above.
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Building C/C++ Extensions for Python: Dec 9-11, Austin, TX http://www.enthought.com/training/building_extensions.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk