Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2008-02-08 14:42:32


Howard Hinnant <hinnant <at> twcny.rr.com> writes:

> template <class L1, class L2>
> void
> lock(L1& l1, L2& l2)
> {
> while (true)
> {
> {
> unique_lock<L1> __u1(l1);
> if (l2.try_lock())
> {
> __u1.release();
> break;
> }
> }
> std::this_thread::yield();

snipped rest of multi-lock code.

> 3. The yields are absolutely necessary to get the high performance
> mentioned in the previous note.

I find this comment intriguing. Is this always the case, or does it depend on
the specifics of how a mutex is implemented on a given platform?

Anthony


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk