backendconcurrencyoop
A mutex should protect an invariant
Anonymous
A mutex should guard an invariant, not just a line that looks shared. If two operations must preserve a relationship between fields, hold the lock across the whole read-check-update sequence. Keep the critical section narrow, but not so narrow that another thread can observe a half-updated state.
0