Crate priomutex [−] [src]
A mutex where waiting threads to specify a priority.
The API is very similar to std::sync::Mutex
. The key difference, of course, is that lock
takes
a priority. If multiple threads are waiting for the mutex when it's freed, the one which gave the
highest priorty will recieve it.
use priomutex::simple::Mutex; let mutex = Arc::new(Mutex::new(0)); for n in 0..3 { let mutex = mutex.clone(); thread::spawn(move|| { loop { { let mut data = mutex.lock(0).unwrap(); *data += 1; } thread::sleep(Duration::from_millis(1000)); } }); }
Modules
spin_one |
A high-performance variant of priomutex. |
Structs
Mutex |
A mutex which allows waiting threads to specify a priority. |
MutexGuard |
An RAII guard. Frees the mutex when dropped. |