Fix example in CP.21 (#1007)

This commit is contained in:
Benoît Blanchon 2017-07-25 17:32:29 +02:00 committed by Sergey Zubkov
parent 69f749bf7f
commit 150744a8d3

View File

@ -13571,12 +13571,12 @@ This is asking for deadlock:
Instead, use `lock()`: Instead, use `lock()`:
// thread 1 // thread 1
lock(lck1, lck2); lock(m1, m2);
lock_guard<mutex> lck1(m1, adopt_lock); lock_guard<mutex> lck1(m1, adopt_lock);
lock_guard<mutex> lck2(m2, adopt_lock); lock_guard<mutex> lck2(m2, adopt_lock);
// thread 2 // thread 2
lock(lck2, lck1); lock(m2, m1);
lock_guard<mutex> lck2(m2, adopt_lock); lock_guard<mutex> lck2(m2, adopt_lock);
lock_guard<mutex> lck1(m1, adopt_lock); lock_guard<mutex> lck1(m1, adopt_lock);