[−][src]Crate global
Type-level safe mutable global access, with support for recursive immutable locking.
use global::Global; // The global value. static VALUE: Global<i32> = Global::new(); // Spawn 100 threads and join them all. let mut threads = Vec::new(); for _ in 0..100 { threads.push(std::thread::spawn(|| { *VALUE.lock_mut().unwrap() += 1; })); } for thread in threads { thread.join().unwrap(); } // This value is guaranteed to be 100. assert_eq!(*VALUE.lock().unwrap(), 100);
Structs
BorrowFail | A failure occured while borrowing a |
Global | A mutable global value. |
GlobalGuard | An immutable handle to some |
GlobalGuardMut | A mutable handle to some |
Immutable | An immutable global value. |