A collection of simple, Fast, and light smart pointers for rust.
Contains faster and lighter alternatives to std smart pointers and much more.
Rc
smart pointer.RefCell
.Arc
with equivalent performanceNonNull
with simpler type deallocation and destructionSync
and Send
Cargo command ->
cargo add speedy_refs
From Cargo.toml ->
[dependencies]
speedy_refs = "0.2.3"
``` use std::thread; use std::sync::{Arc, Barrier}; use speedy_refs::Reon;
fn main() { let x = Reon::new(42); let numthreads = 4; let barrier = Arc::new(Barrier::new(numthreads));
let mut threads = Vec::with_capacity(num_threads);
for _ in 0..num_threads {
let x = x.clone();
let barrier = Arc::clone(&barrier);
let thread = thread::spawn(move || {
barrier.wait();
println!("Thread {:?} sees value: {}", thread::current().id(), *x);
});
threads.push(thread);
}
for thread in threads {
thread.join().unwrap();
}
}
```
MIT license