3 releases

0.1.2 Jul 26, 2022
0.1.1 Jul 26, 2022
0.1.0 Jul 26, 2022

#741 in Concurrency

Download history 267/week @ 2023-06-07 256/week @ 2023-06-14 319/week @ 2023-06-21 462/week @ 2023-06-28 199/week @ 2023-07-05 119/week @ 2023-07-12 110/week @ 2023-07-19 80/week @ 2023-07-26 271/week @ 2023-08-02 409/week @ 2023-08-09 381/week @ 2023-08-16 639/week @ 2023-08-23 655/week @ 2023-08-30 633/week @ 2023-09-06 671/week @ 2023-09-13 338/week @ 2023-09-20

2,442 downloads per month

MIT license

5KB
73 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–32MB
~441K SLoC