ocean icon indicating copy to clipboard operation
ocean copied to clipboard

Use mmap to simplify ring buffer

Open mathias-baumann-sociomantic opened this issue 7 years ago • 0 comments

Using mmap we can greatly simplify our ring buffer implementation. Basically, we can get rid of all the extra logic required at the wrap-around position.

Mmap allows us to remap the beginning of the buffer to after the end so that a continuous read/write can be done.

Here is a working POSIX implementation that we can copy from: https://en.wikipedia.org/w/index.php?title=Circular_buffer&oldid=588930355#Optimized_POSIX_implementation