Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-01-10 14:28:19

Hello Peter,

Wednesday, January 10, 2007, 12:02:17 AM, you wrote:

> You should also consider not extending the critical sections beyond the
> minimum necessary, as in

> locking_state_machine& operator= (locking_state_machine const& that)
> {
> scoped_lock that_lock( that.m_Mutex );
> base_type tmp( that );
> that_lock.unlock();

> scoped_lock this_lock( m_Mutex );
> tmp.swap( *this );
> this_lock.unlock();

> return *this;
> }

I thought about something like this and decided not to do it. The
implementation has no support for "swap" and it would not be an easy
and convenient for users thing to implement it. Besides, the
assignment creates an additional copy of the machine which is at least
not intuitive for users and may considerably increase performance cost.

Best regards,
 Andrey                            mailto:andysem_at_[hidden]

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