logoalt Hacker News

binarycoffeelast Tuesday at 5:38 PM1 replyview on HN

I hope you won't mind my picking your brain: which MPSC ring buffer implementations did you find that does drop old items when full? I could only found implementations that are basically re-purposed MPMC, or that cannot deal with non-POD data (seqlock-based).


Replies

nlylast Tuesday at 9:16 PM

Generally I find it's best to implement push operations as try_push operations and let the caller decide if they want to drop, or spin.

There are definitely designs that can deal with non-POD data of variable size, although that does imply heterogeneous types, which will need some sort of type erasure to destroy safely.