#ring-buffer #spsc

indexed-ring-buffer

An indexed multiple readable spsc ring buffer

4 releases

0.1.3 Feb 13, 2020
0.1.2 Feb 4, 2020
0.1.1 Jan 31, 2020
0.1.0 Jan 31, 2020

#243 in Concurrency

Download history 4/week @ 2020-05-22 8/week @ 2020-05-29 4/week @ 2020-06-05 4/week @ 2020-06-12 8/week @ 2020-07-03 8/week @ 2020-07-10 4/week @ 2020-07-17 1/week @ 2020-07-24 8/week @ 2020-08-07 4/week @ 2020-08-14 5/week @ 2020-08-21 10/week @ 2020-08-28 13/week @ 2020-09-04

67 downloads per month

MIT/Apache

14KB
288 lines

Indexed Ring Buffer

An indexed multiple readable spsc ring buffer.

Overview

  • access by an absolute index.
  • a single-producer single-consumer with multi-reader.
  • using RwLock of parking_lot.

Examples

extern crate indexed_ring_buffer;
use indexed_ring_buffer::*;

let (mut p, mut c, r) = indexed_ring_buffer::<usize>(0, 5);

for i in 0..101 {
    p.push(i);
    c.shift();
}

for i in 101..106 {
    p.push(i);
}

let (start, end, data) = r.get_from(101,5).unwrap();
assert_eq!(data,vec![101,102,103,104,105]);
assert_eq!(start,101);
assert_eq!(end,105);

c.shift_to(105);
let rslt = r.get_all();
assert_eq!(rslt,None);

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~560KB
~11K SLoC