Boost logo

Boost :

Subject: Re: [boost] [mutex] move / merge
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2011-05-18 12:48:42

Phil Bouchard <philippe_at_[hidden]> writes:

> On 5/18/2011 8:45 AM, Mathias Gaunard wrote:
>> Combining the locking of multiple mutexes requires defining an order in
>> which they should always be acquired so as to define a lock hierarchy.
>> Using the address of the mutex in question for that ordering should work.
> That's unfortunate because it'll uglify the code. A more important
> problem is that "ps_->redir()->mutex_" and "p.ps_->redir()->mutex_"
> need to be called in a lock mode right before. For that I need to
> lock a global mutex, which I was trying not to do.

Using boost::lock() you don't have to worry about defining an ordering;
boost::lock() will take care of it for you.


Author of C++ Concurrency in Action
just::thread C++0x thread library   
Just Software Solutions Ltd
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost list run by bdawes at, gregod at, cpdaniel at, john at