Skip to content

Comment on Correctly implementing a spinlock in Modern C++parent

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)

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.