mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Fix example in CP.21 (#1007)
This commit is contained in:
parent
69f749bf7f
commit
150744a8d3
|
@ -13571,12 +13571,12 @@ This is asking for deadlock:
|
|||
Instead, use `lock()`:
|
||||
|
||||
// thread 1
|
||||
lock(lck1, lck2);
|
||||
lock(m1, m2);
|
||||
lock_guard<mutex> lck1(m1, adopt_lock);
|
||||
lock_guard<mutex> lck2(m2, adopt_lock);
|
||||
|
||||
// thread 2
|
||||
lock(lck2, lck1);
|
||||
lock(m2, m1);
|
||||
lock_guard<mutex> lck2(m2, adopt_lock);
|
||||
lock_guard<mutex> lck1(m1, adopt_lock);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user