How does C++ name lock_guards and unique_locks?
This article mainly explains "how C++ names lock_guards and unique_locks". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how C++ names lock_guards and unique_locks.
CP.44: remember to name lock_guards and unique_locks
Reason (reason)
An unnamed local objects is a temporary that immediately goes out of scope.
An unnamed local variable is a temporary variable that leaves scope immediately.
Example (sample)
Unique_lock (M1)
Lock_guard {m2}
Lock (M1, m2)
This looks innocent enough, but it isn't.
There seems to be nothing wrong with the code, but this is not the case.
Enforcement (implementation recommendations)
Flag all unnamed lock_guards and unique_locks.
Mark all unnamed lock_guard and unique_locks.
At this point, I believe you have a deeper understanding of "how C++ names lock_guards and unique_locks". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!