Advertisement
oster_man

lock_guard_order

Aug 20th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. struct Access { //все работает хорошо
  2.         std::lock_guard<mutex> guard;
  3.         Value& ref_to_value;
  4.        
  5.         Access(const Key& key, Bucket& bucket):
  6.             guard(bucket.locker),
  7.             ref_to_value(bucket.dictionary[key])
  8.             {}
  9.     };
  10.  
  11. struct Access { //ловлю ассерт (не потокобезопасно)
  12.         Value& ref_to_value;
  13.         std::lock_guard<mutex> guard;
  14.        
  15.         Access(const Key& key, Bucket& bucket):
  16.             guard(bucket.locker),
  17.             ref_to_value(bucket.dictionary[key])
  18.             {}
  19.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement