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

1

u/david-alvarez-rosa Mar 24 '26

The example forces the type. It would be interesting to see how it could be generalized, but not a big fan of heterogeneous containers tbh

2

u/SirClueless Mar 25 '26

If the data is inherently heterogeneous, it's the least-bad option. For example if the items in the queue are network packets.

2

u/RogerV Mar 25 '26

in DPDK all the ring buffers just hold pointers to packets - the packets are in an mbuf pool. makes it possible to clone a ref count on a packet - say, into a pcap ring buffer.