Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-01-09 15:56:35

Hello Steven,

Tuesday, January 9, 2007, 11:29:04 PM, you wrote:


> Andrey Semashev wrote:
>> Right, thanks for finding this. I'll try to fix it. I guess, I'll have
>> to create a global mutex object for the assignment operations and lock
>> it prior to other two locks and assignment.
> I think that this works:
> locking_state_machine& operator= (locking_state_machine const& that)
> {
> if(boost::addressof(that) != this) {
> const bool lock_this_first = boost::addressof(m_Mutex) <
> boost::addressof(that.m_Mutex);
> scoped_lock that_lock(lock_this_first? m_Mutex : that.m_Mutex);
> scoped_lock this_lock(lock_this_first? that.m_Mutex : m_Mutex);
> base_type::operator= (static_cast< base_type const& >(that));
> }
> return *this;
> }

Wow, that's really great! That'll surely address the problem with
non-template operator. I'll think it over if something like this could
be made for the template one. Thanks for the idea!

Best regards,
 Andrey                            mailto:andysem_at_[hidden]

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