Double Mapped Circular Buffer
- Thread-safe.
- Supports multiple readers.
- Generic over the item type.
- Provides access to all items (not n-1).
- Supports Linux, macOS, Windows, and Android.
- Sync, async, and non-blocking implementations.
- Generic variant that allows specifying custom
Notifiers
to ease integration. - Underlying data structure (i.e.,
DoubleMappedBuffer
) is exported to allow custom implementations.
Overview
This circular buffer implementation maps the underlying buffer twice, back-to-back into the virtual address space of the process. This arrangement allows the circular buffer to present the available data sequentially, (i.e., as a slice) without having to worry about wrapping.
Example
use sync;
let mut w = ?;
let mut r = w.add_reader;
// delay producing by 1 sec
let now = now;
let delay = from_millis;
// producer thread
spawn;
// blocks until data becomes available
let r_buff = r.slice.unwrap;
assert!;
for v in r_buff
let l = r_buff.len;
r.consume;
Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the project, shall be licensed as Apache 2.0, without any additional terms or conditions.