#ring #buffer #magic #virtual #mirrored

nightly magic-ring-buffer

A magic ring buffer (also known as a virtual ring buffer, VRB, or mirrored buffer) which is lock-free for multiple producers and a single consumer

1 unstable release

0.1.0 Feb 2, 2019

#9 in #magic


Used in message-dispatch

MIT license

31KB
617 lines

magic-ring-buffer

magic-ring-buffer is a Rust crate providing a magic ring buffer (also known as a virtual ring buffer, VRB, or mirrored buffer) which is lock-free for multiple producers and a single consumer.

A magic ring buffer allows 'wrap-around' of a ring buffer without the need to use two separate read or two separate writes; it exploits the fact that virtual memory does not need to be implemented using contiguous physical memory.

The current design only works on Linux-like systems, as it relies on mapping files in /dev/shm.

It should be possible to make implementations that work on Mac OS X, the BSDs and Windows.

Licensing

The license for this project is MIT.


lib.rs:

#magic-ring-buffer

This is a Rust crate providing a magic ring buffer (also known as a virtual ring buffer, VRB, or mirrored buffer) which is lock-free for multiple producers and a single consumer.

A magic ring buffer allows 'wrap-around' of a ring buffer without the need to use two separate read or two separate writes; it exploits the fact that virtual memory does not need to be implemented using contiguous physical memory.

The current implementation only works on Android and Linux, as it relies on mapping anonymous shared memory in /dev/shm. It should be possible to make implementations that work on Mac OS X, the BSDs and Windows.

Dependencies

~0–520KB