Boost logo

Boost :

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


Phil Bouchard <philippe_at_[hidden]> writes:

> On 5/17/2011 10:56 PM, Phil Bouchard wrote:
>>
>> Sorry for the confusion but it turns out I won't need this operation
>> either.
>
> The bottom line is I would need a ~mutex() that discards errors and an
> atomic way of performing the following consecutive locks:
>
> template <typename V>
> block_ptr & operator = (block_ptr<V> const & p)
> {
> mutex::scoped_lock scoped_lock1(ps_->redir()->mutex_);
> mutex::scoped_lock scoped_lock2(p.ps_->redir()->mutex_);
>
> ...
> }

Is boost::lock() any help here? It will lock multiple mutexes without
deadlock due to ordering concerns.

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