5 releases

Uses old Rust 2015

0.1.4 Feb 5, 2018
0.1.3 Jan 6, 2018
0.1.2 Sep 27, 2017
0.1.1 May 5, 2017
0.1.0 May 5, 2017

#1132 in Concurrency

Download history 158/week @ 2024-07-27 146/week @ 2024-08-03 150/week @ 2024-08-10 104/week @ 2024-08-17 126/week @ 2024-08-24 181/week @ 2024-08-31 79/week @ 2024-09-07 110/week @ 2024-09-14 117/week @ 2024-09-21 107/week @ 2024-09-28 29/week @ 2024-10-05 85/week @ 2024-10-12 92/week @ 2024-10-19 73/week @ 2024-10-26 96/week @ 2024-11-02 35/week @ 2024-11-09

301 downloads per month
Used in 27 crates (10 directly)

MIT license

10KB
164 lines

atomic_immut

Documentation Build Status Code Coverage License: MIT

Atomic immutable value for Rust.

Documentation


lib.rs:

Atomic immutable value.

Examples

use std::sync::Arc;
use std::thread;
use atomic_immut::AtomicImmut;

let v = Arc::new(AtomicImmut::new(vec![0]));
{
    let v = v.clone();
    thread::spawn(move || {
                      let mut new = (&*v.load()).clone(); // Loads the immutable reference
                      new.push(1);
                      v.store(new); // Replaces the existing value
                  });
}
while v.load().len() == 1 {}
assert_eq!(&*v.load(), &vec![0, 1]);

No runtime deps