
28 Apr
2005
28 Apr
'05
5:53 p.m.
Michael Glassford wrote: [...] I'll think about your suggestion a bit more before I'll be able to comment, but just a quick note:
l = m.lock(); //Lock mutex m (first unlocking whatever mutex l was previously locking, if any)
This is not what will happen. m.lock() is executed first, then operator= is called and l is given the opportunity to release its lock. So if l happens to already hold m.lock(), the thread will deadlock. (And a deadlock can also occur if another thread holds a lock on m and is blocked on the mutex currently locked by l.)