Double Mapped Circular Buffer

Crates.io Apache 2.0 licensed Build Status

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

```rust use vmcircbuffer::sync;

let mut w = sync::Circular::new::()?; let mut r = w.add_reader();

// delay producing by 1 sec let now = std::time::Instant::now(); let delay = std::time::Duration::from_millis(1000);

// producer thread std::thread::spawn(move || { std::thread::sleep(delay); let wbuff = w.slice(); for v in wbuff.itermut() { *v = 23; } let l = wbuff.len(); w.produce(l); });

// blocks until data becomes available let rbuff = r.slice().unwrap(); assert!(now.elapsed() > delay); for v in rbuff { asserteq!(*v, 23); } let l = rbuff.len(); r.consume(l); ```

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.