3 ms·
> That said I have seen several incorrect and unnecessary `CompareExchange` usages that could have been avoided with a simple lock... This is, obviously, the a
by Sharlin 10y ago
> That said I have seen several incorrect and unnecessary `CompareExchange` usages that could have been avoided with a simple lock...
This is, obviously, the answer to the GP's question.
- TillE 10y agoThat's no reason for avoiding atomics in simple use cases. "Use locks and then profile" is fairly bad advice. Forget the profiler and always use atomics in simple situations where you know exactly how they work. Just don't try anything complicated with them.