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