Subject: Re: [boost] [mutex] move / merge
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-05-18 11:45:06


On 05/18/2011 12:17 AM, Phil Bouchard wrote:
> 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_);
>
> ...
> }

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.