Comment on Correctly implementing a spinlock in Modern C++parentComments−spacechild15yYour reasoning is correct. Also, if it makes you sleep better :-), here's the boost implementation of a spinlock:https://github.com/boostorg/sync/blob/dfdf317f63d26fb40c703b...It has been written by an expert in lockfree programming (Tim Blechmann)−albertzeyer5yI wonder, there was this change/fix:https://github.com/boostorg/sync/commit/1b5aaa4a0b7ef4fad2a4...−spacechild15yThe title "Corrected memory order in some cases" is a bit misleading because the original code was correct. The commit just relaxes some unnecessarily strict memory orderings (to improve performance on platforms with weak memory models).BTW, the spinlock implementation is not affected.
Comments
Your reasoning is correct. Also, if it makes you sleep better :-), here's the boost implementation of a spinlock:
https://github.com/boostorg/sync/blob/dfdf317f63d26fb40c703b...
It has been written by an expert in lockfree programming (Tim Blechmann)
I wonder, there was this change/fix:
https://github.com/boostorg/sync/commit/1b5aaa4a0b7ef4fad2a4...
The title "Corrected memory order in some cases" is a bit misleading because the original code was correct. The commit just relaxes some unnecessarily strict memory orderings (to improve performance on platforms with weak memory models).
BTW, the spinlock implementation is not affected.