|
Boost : |
From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-10-18 12:32:12
From: "David Abrahams" <dave_at_[hidden]>
> "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.
> > When
> > 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 &, ...);
> > };
> >
> > or
> >
> > 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);
> > f();
> > }
> >
> > 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.
As do I.
Bill Kempf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk