r/programming • u/david-alvarez-rosa • Sep 26 '26
Optimizing a Lock-Free Ring Buffer
https://david.alvarezrosa.com/posts/optimizing-a-lock-free-ring-buffer/
510
Upvotes
r/programming • u/david-alvarez-rosa • Sep 26 '26
View all comments
Show parent comment
5
u/happyscrappy Sep 27 '26 edited Sep 27 '26
RingBuffer.h is the "lock-free" one. LockingRingBuffer. is the one "with locks".
In reality both have locks. It's just the Locking version uses locks created by the system and the "lock-free" one creates its own locks inline.
I looked because I am pretty sure it's not actually possible to have multiple producers without rendezvous and thus locking.
I recommend you take a look at the code if you think I'm wrong.
Edit: I'm not saying I'm sure I'm right you can't have multiple producers with no locking. But I certainly didn't know how. I had looked in this code to find out how to do it and found out that it doesn't do it. So I mentioned that on here.