• Home
  • Raw
  • Download

Lines Matching full:mutex

13 /// This mutex will block threads waiting for the lock to become available. The
14 /// mutex can also be statically initialized or created via a `new`
15 /// constructor. Each mutex has a type parameter which represents the data that
18 /// ever accessed when the mutex is locked.
23 /// quickly acquires and releases the same mutex in succession, which can starve
24 /// other threads waiting to acquire the mutex. While this improves throughput
26 /// a mutex it has just released, this can starve other threads.
28 /// This mutex uses [eventual fairness](https://trac.webkit.org/changeset/203350)
31 /// which will force the lock to go to the next thread waiting for the mutex.
38 /// unlocking a mutex instead of simply dropping the `MutexGuard`.
40 /// # Differences from the standard library `Mutex`
44 /// `Mutex` due to platform limitations.
50 /// - Supports eventual fairness so that the mutex is fair on average.
51 /// - Optionally allows making the mutex fair by calling `MutexGuard::unlock_fair`.
56 /// use parking_lot::Mutex;
66 /// // the Arc is protected with a mutex.
67 /// let data = Arc::new(Mutex::new(0));
87 pub type Mutex<T> = lock_api::Mutex<RawMutex, T>; typedef
89 /// Creates a new mutex in an unlocked state ready for use.
91 /// This allows creating a mutex in a constant context on stable Rust.
92 pub const fn const_mutex<T>(val: T) -> Mutex<T> { in const_mutex()
93 Mutex::const_new(<RawMutex as lock_api::RawMutex>::INIT, val) in const_mutex()
96 /// An RAII implementation of a "scoped lock" of a mutex. When this structure is
99 /// The data protected by the mutex can be accessed through this guard via its
103 /// An RAII mutex guard returned by `MutexGuard::map`, which can point to a
114 use crate::{Condvar, Mutex};
123 struct Packet<T>(Arc<(Mutex<T>, Condvar)>);
133 let m = Mutex::new(()); in smoke()
143 let m = Arc::new(Mutex::new(0)); in lots_and_lots()
145 fn inc(m: &Mutex<u32>) { in lots_and_lots()
176 let m = Mutex::new(()); in try_lock()
182 let m = Mutex::new(NonCopy(10)); in test_into_inner()
195 let m = Mutex::new(Foo(num_drops.clone())); in test_into_inner_drop()
206 let mut m = Mutex::new(NonCopy(10)); in test_get_mut()
213 let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); in test_mutex_arc_condvar()
238 let arc = Arc::new(Mutex::new(1)); in test_mutex_arc_nested()
239 let arc2 = Arc::new(Mutex::new(arc)); in test_mutex_arc_nested()
252 let arc = Arc::new(Mutex::new(1)); in test_mutex_arc_access_in_unwind()
256 i: Arc<Mutex<i32>>, in test_mutex_arc_access_in_unwind()
273 let mutex: &Mutex<[i32]> = &Mutex::new([1, 2, 3]); in test_mutex_unsized() localVariable
275 let b = &mut *mutex.lock(); in test_mutex_unsized()
280 assert_eq!(&*mutex.lock(), comp); in test_mutex_unsized()
287 let mutex = Mutex::new(()); in test_mutexguard_sync() localVariable
288 sync(mutex.lock()); in test_mutexguard_sync()
293 let mutex = Mutex::new(vec![0u8, 10]); in test_mutex_debug() localVariable
295 assert_eq!(format!("{:?}", mutex), "Mutex { data: [0, 10] }"); in test_mutex_debug()
296 let _lock = mutex.lock(); in test_mutex_debug()
297 assert_eq!(format!("{:?}", mutex), "Mutex { data: <locked> }"); in test_mutex_debug()
304 let mutex = Mutex::new(contents.clone()); in test_serde() localVariable
306 let serialized = serialize(&mutex).unwrap(); in test_serde()
307 let deserialized: Mutex<Vec<u8>> = deserialize(&serialized).unwrap(); in test_serde()
309 assert_eq!(*(mutex.lock()), *(deserialized.lock())); in test_serde()