2 ms·
> forgetting to synchronize at all, inconsistent locking At least for these two classes of categories, mutex usage at Google is broadly paired with compiler-en
by vitus 4y ago
> forgetting to synchronize at all, inconsistent locking
At least for these two classes of categories, mutex usage at Google is broadly paired with compiler-enforced annotations to enforce that _all_ accesses to mutex-guarded member variables are done while holding the appropriate mutex.
https://abseil.io/docs/cpp/guides/synchronization#thread-annotations https://abseil.io/docs/cpp/guides/synchronization#thread-ann...
(While yes, it can also help with deadlock avoidance as well, that tends to be trickier to enforce across the board, especially if the mutexes in question belong to different objects. There's separate deadlock detection baked into Abseil that's used primarily in non-production builds.)