about summary refs log tree commit diff
path: root/library/std/src/sync/rwlock.rs
AgeCommit message (Collapse)AuthorLines
2021-03-28Rollup merge of #83561 - m-ou-se:lock-debug, r=jackh726Yuki Okushi-4/+8
Improve Debug implementations of Mutex and RwLock. This improves the Debug implementations of Mutex and RwLock. They now show the poison flag and use debug_non_exhaustive. (See #67364.)
2021-03-27Improve Debug implementations of Mutex and RwLock.Mara Bos-4/+8
They now show the poison flag and use debug_non_exhaustive.
2021-03-27Fix Debug implementation for RwLock{Read,Write}Guard.Mara Bos-2/+2
This would attempt to print the Debug representation of the lock that the guard has locked, which will try to lock again, fail, and just print "<locked>" unhelpfully. After this change, this just prints the contents of the mutex, like the other smart pointers (and MutexGuard) do.
2021-02-27Update library/std/src/sync/rwlock.rsAleksey Kladov-1/+1
Co-authored-by: Steven Fackler <sfackler@gmail.com>
2021-02-27clarify RW lock's priority gotchaAleksey Kladov-1/+3
In particular, the following program works on Linux, but deadlocks on mac: use std::{ sync::{Arc, RwLock}, thread, time::Duration, }; fn main() { let lock = Arc::new(RwLock::new(())); let r1 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r1/1"); sleep(1000); let _rg = lock.read(); eprintln!("r1/2"); sleep(5000); } }); sleep(100); let w = thread::spawn({ let lock = Arc::clone(&lock); move || { let _wg = lock.write(); eprintln!("w"); } }); sleep(100); let r2 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r2"); sleep(2000); } }); r1.join().unwrap(); r2.join().unwrap(); w.join().unwrap(); } fn sleep(ms: u64) { std::thread::sleep(Duration::from_millis(ms)) }
2020-09-20Replace unneeded `unsafe` calls to `.get()` with calls to `.get_mut()`Daniel Henry-Mantilla-3/+1
2020-09-06Auto merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAusbors-2/+2
Use Arc::clone and Rc::clone in documentation This PR replaces uses of `x.clone()` by `Rc::clone(&x)` (or `Arc::clone(&x)`) to better match the documentation for those types. @rustbot modify labels: T-doc
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-251/+3
Also doing fmt inplace as requested.
2020-08-30Move to Arc::clone(&x) over x.clone() in library/stdAlexis Bourget-2/+2
2020-08-22Use intra-doc-links in `std::sync::*`LeSeulArtichaut-13/+5
2020-07-27mv std libs to library/mark-0/+799