#cell #lock-free #reader-writer #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

#263 in Concurrency

Download history 273/week @ 2024-06-19 319/week @ 2024-06-26 190/week @ 2024-07-03 156/week @ 2024-07-10 58/week @ 2024-07-17 142/week @ 2024-07-24 136/week @ 2024-07-31 292/week @ 2024-08-07 270/week @ 2024-08-14 422/week @ 2024-08-21 512/week @ 2024-08-28 513/week @ 2024-09-04 261/week @ 2024-09-11 468/week @ 2024-09-18 486/week @ 2024-09-25 315/week @ 2024-10-02

1,611 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