4 ms·
> Sure: maybe the first read happening concurrently with the write won't read true yet but surely the next one or the one after must? You are expecting the rea
by junke 8y ago
> Sure: maybe the first read happening concurrently with the write won't read true yet but surely the next one or the one after must?
You are expecting the read operation to be done either before or after the write, which would be the case if atomicity was guaranteed.
There might be ugly intermediate states, or maybe there aren't, but don't know because there are no guarantees.
See also: http://preshing.com/20130618/atomic-vs-non-atomic-operations/ http://preshing.com/20130618/atomic-vs-non-atomic-operations...
- dualogy 8y ago> There might be ugly intermediate states In the general case: absolutely! In the above very specific setup as I outlined it (one bool, a single writer, a simple-waiting-for-that-single-write-loop) --- not. (Hence my point that another equally-tiny snippet might make the issue much more locally-reproducable-and-experienceable even without `-race`.)