about summary refs log tree commit diff
path: root/library/std/src/sync/rwlock.rs
AgeCommit message (Collapse)AuthorLines
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-2/+2
2021-09-28ref/refmutGus Wynn-1/+1
2021-09-27lock typesGus Wynn-0/+12
2021-06-28Auto merge of #82624 - ojeda:rwlock-example-deadlock, r=JohnTitorbors-1/+13
RWLock: Add deadlock example Suggested in https://github.com/rust-lang/rust/pull/82596 but it was a bit too late. `@matklad` `@azdavis` `@sfackler`
2021-06-01Multiple improvements to RwLocksBenoƮt du Garreau-30/+4
- Split `sys_common::RWLock` between `StaticRWLock` and `MovableRWLock` - Unbox `RwLock` on some platforms (Windows, Wasm and unsupported) - Simplify `RwLock::into_inner`
2021-05-24minor rewording after reviewTaylor Yu-4/+4
Use "the `WouldBlock` error" instead of "the error `WouldBlock`", etc.
2021-05-20doc: clarify Mutex::try_lock, etc. errorsTaylor Yu-7/+20
Clarify error returns from Mutex::try_lock, RwLock::try_read, RwLock::try_write to make it more obvious that both poisoning and the lock being already locked are possible errors.
2021-04-22Move `sys_common::poison` to `sync::poison`Christiaan Dirkx-1/+1
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-03-05RWLock: Add deadlock exampleMiguel Ojeda-1/+13
Suggested in https://github.com/rust-lang/rust/pull/82596 but it was a bit too late. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
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