r/programming • • Sep 26 '26

Optimizing a Lock-Free Ring Buffer

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

89 comments sorted by

View all comments

Show parent comment

1

u/aePrime Sep 28 '26

So by everybody’s logic, an algorithm cannot have a looping atomic compare and swap and be considered lock-free. The atomic waits can be written as a CAS, they just don’t spin the same way.

2

u/happyscrappy Sep 28 '26

Just so you know, others do consider this lock-free. There is a poster who responded to me with a good and informative post. I personally find that to be a useless distinction when you just spin on a different value instead of a lock take.

I don't think you can do multiple producers without waiting, which is what I associate with locking. But by the terminology you can do it without locking.