|
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.
Anthony
-- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk