
20 Jul
2007
20 Jul
'07
10:12 p.m.
Phillip Hellewell wrote:
However, even the simplest _assignable_ class seems almost impossible to me to make thread-safe. You can synchronize operator= using both its own mutex(es) and rhs's mutex(es), which seems to solve the problem. But how do you prevent deadlock from something like this?
Thread 1: x = y Thread 2: y = x
One common method is to perform the locks based on ordering of the mutex's memory address. That way all threads are locking and releasing in the same order. Michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com