r/cpp • • Mar 24 '26

Optimizing a Lock-Free Ring Buffer

https://david.alvarezrosa.com/posts/optimizing-a-lock-free-ring-buffer/
106 Upvotes

58 comments sorted by

View all comments

Show parent comment

3

u/SkoomaDentist Antimodern C++, Embedded, Audio Mar 25 '26

Writing lock-free code that works under all circumstances - or even works provably 100% reliably on one application - is extremely tricky.

Hell, writing locking code that does that is already tricky enough as soon as you move to fine grained locking. I wish there were tried and tested standalone lock free implementation of the most common structures that were actually lock free instead of the usual "let's fall back to locking because obviously lock free is always purely a throughput optimization" (spoiler: It is very much not).