logoalt Hacker News

nlytoday at 9:17 AM1 replyview on HN

Most people implement them now in my field using mmap tricks so the CPU can do the wraparound for you in virtual memory.

Makes the code trivial


Replies

thrtythreefortytoday at 2:28 PM

Not only that, but you can also always form a normal (ptr, size) slice reference to any piece of the ring buffer, even when it wraps. This is really helpful for Eigen arrays that you need to rotate.