1.9
C++ Concurrency in Action Anthony Williams
Chapter 3. Sharing data between threads
3.2.3 Spotting race conditions inherent in interfaces
3.2.4 Deadlock: the problem and a solution
The common advice for avoiding deadlock is to alwasy lock the two mutexes in the same order
3.2.5 Further guidelines for avoiding deadlock
Don't wait for another thread if there's a chance it's waiting for you.
Avoid nested locks: don't acquire a lock if you already hold one.
Avoid calling user-supplied code while holding a lock
Acquire locks in a fixed order.
Use a lock hierarchy.
3.2.6 Flexible locking with std::unique_lock