It looks like it is to reorder the destruction of the __lock
and __my_lock
variables.
The calls should look like this:
construct __my_lock // locks _M_mutexconstruct __unlock // unlocks __lockconstruct __my_lock2 // Does nothing as its a move._M_cond.wait(__my_lock2);destroy __mylock2 // unlocks __M_mutexdestroy __unlock // locks __lock againdestroy __mylock // does nothing as its been moved
Without the move the order would be
construct __my_lock // locks _M_mutexconstruct __unlock // unlocks __lock_M_cond.wait(__my_lock);destroy __unlock // locks __lockdestroy __mylock // unlocks _M_mutex
Which can result in deadlock as mentioned in the other answer