Module reffers::arc

source ·
Expand description

This is somewhat like an Arc<RwLock<T>>, but with only one usize of overhead, and the lock is a spinlock (there is no wait-and-sleep functionality).

Conceptually similar to rc, but this is a thread-safe version.

Example

use std::thread;
use reffers::arcu::Strong;

let s = Strong::<_>::new(987i32);
let s2 = s.clone();
thread::spawn(move || {
    *s2.get_refmut() = 654i32;
}).join().unwrap();
assert_eq!(*s.get_ref(), 654i32);

Structs

An Rc reference which has immutable access to the inner value.
An Arc which has mutable access to the inner value. Only one RefMut can exist, and cannot coexist with any Ref.
A strong reference without access to the inner value.
A weak reference without access to the inner value.

Traits

This is an implementation detail. Please don’t mess with it.