3 releases
0.1.0-alpha.3 | Nov 12, 2024 |
---|---|
0.1.0-alpha.1 | Nov 11, 2024 |
#122 in Caching
86 downloads per month
12KB
275 lines
lazy_catch
lib.rs
:
let mut system = System::new();
let arc_x = std::sync::Arc::new(system.var(0));
assert_eq!(*system.get(&*arc_x), 0);
let a = system.val(|mut u: Update<i32>| {
let v = *u.get(&*arc_x);
u.update(|| v + 1);
});
assert_eq!(*system.get(&a), 1);
let arc_x_clone = arc_x.clone();
let b = system.sync_val(move |mut u: Update<i32>| {
let v = *u.get(&*arc_x_clone);
u.update(|| v + 2);
});
let mut modify = system.modify();
*arc_x.modify(&mut modify) = 10;
std::thread::spawn(move || {
assert_eq!(*system.get(&b), 12);
}).join().unwrap();