left-right-cell

Crates.ioleft-right-cell
lib.rsleft-right-cell
version0.1.3
sourcesrc
created_at2022-07-26 15:13:06.233771
updated_at2024-01-20 16:58:22.907375
descriptionA cell with lock-free concurrent read access.
homepagehttps://github.com/Kl4rry/left-right-cell
repositoryhttps://github.com/Kl4rry/left-right-cell
max_upload_size
id633237
size5,069
Axel Kappel (Kl4rry)

documentation

https://docs.rs/left-right-cell

README

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);
Commit count: 4

cargo fmt