4 ms·
What stops you from manually entering a critical region yourself before you do the assignment?
by Senji 10y ago
What stops you from manually entering a critical region yourself before you do the assignment?
- Manishearth 10y agoCould you elaborate on what you mean here? The compiler stops you from trying to mutate things when they're not uniquely owned or atomic (or behind a mutex). When you have a non-unique reference you need to use a bunch of unsafe function calls to force mutation on it.
- seeekr 10y agoNot GP, but iiuc he is just stating: In order to prevent these kinds of race conditions you can just use any regular locking mechanism. (As you could with many other cases where you'd like to introduce atomicity manually.)
- Manishearth 10y agoRight, and the compiler forces you to do so.