Crate crossbeam_arccell[−][src]
This library provides a Software Transactional Memory structure that can be used for sharing data among multiple threads in a way that is safe and can be loaded quickly.
For more information, look at the documentation for the Stm
struct.
Example
use crossbeam_arccell::ArcCell; // Create a new ArcCell with a Vec of numbers let arc = ArcCell::new(vec![1,2,3,4]); // Read from the ArcCell { let data = arc.load(); println!("Current ArcCell value: {:?}", data); } // Update the ArcCell pointer to add a new number arc.update(|old| { let mut new = old.clone(); new.push(5); new }); // Read the new data { let data = arc.load(); println!("Current ArcCell: {:?}", data); } // Set the ArcCell pointer let data = vec![9,8,7,6]; arc.set(data); // Read the new data, again { let data = arc.load(); println!("Current ArcCell: {:?}", data); }
Structs
ArcCell |
An updatable Arc. |
ArcCellGuard |
Structure that ensures any loaded data won't be freed by a future update. |