#atomic

atomic_immut

Atomic immutable value

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

#87 in #atomic

Download history 202/week @ 2022-04-21 114/week @ 2022-04-28 155/week @ 2022-05-05 211/week @ 2022-05-12 123/week @ 2022-05-19 155/week @ 2022-05-26 203/week @ 2022-06-02 156/week @ 2022-06-09 122/week @ 2022-06-16 154/week @ 2022-06-23 175/week @ 2022-06-30 164/week @ 2022-07-07 102/week @ 2022-07-14 113/week @ 2022-07-21 97/week @ 2022-07-28 167/week @ 2022-08-04

517 downloads per month
Used in 25 crates (10 directly)

MIT license

10KB
164 lines

atomic_immut

Crates.io: 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