#lock-free #reader-writer #cell #consistent #access #read

left-right-cell

A cell with lock-free concurrent read access

4 releases

0.1.3 Jan 20, 2024
0.1.2 Jul 26, 2022
0.1.1 Jul 26, 2022
0.1.0 Jul 26, 2022

#346 in Concurrency

Download history 39/week @ 2024-07-19 225/week @ 2024-07-26 123/week @ 2024-08-02 350/week @ 2024-08-09 298/week @ 2024-08-16 455/week @ 2024-08-23 514/week @ 2024-08-30 433/week @ 2024-09-06 213/week @ 2024-09-13 563/week @ 2024-09-20 453/week @ 2024-09-27 351/week @ 2024-10-04 208/week @ 2024-10-11 152/week @ 2024-10-18 157/week @ 2024-10-25 427/week @ 2024-11-01

1,019 downloads per month

MIT license

6KB
81 lines

left-right-cell

left-right-cell is a lockfree, eventually consistent cell created using the left-right crate. It allows readers to read from the cell without ever blocking while the writer might block when writing. This is achived by storing two copies of the data one for the readers and one for the writer.

let (mut w, r) = left_right_cell::new(false);

let t = std::thread::spawn(move || {
    loop {
        let value = r.get().unwrap();
        if *value {
            break;
        }
    }
});

w.set(true);
w.publish();
t.join().unwrap();
assert!(true);

lib.rs:

left-right-cell is a lockfree, eventually consistent cell created using the left-right crate. It allows readers to read from the cell without ever blocking while the writer might block when writing. This is achived by storing to copies of the data one for the readers and one for the writer.

Dependencies

~0.1–26MB
~329K SLoC