diff options
| author | bors <bors@rust-lang.org> | 2021-06-28 09:58:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-06-28 09:58:06 +0000 |
| commit | 17ea490310ba7c836c93fe1b7002555b3bea5eb1 (patch) | |
| tree | 5426183fc0b8fab436cd8e231e76a6a4513f853d | |
| parent | 451e98e7b02c8bf5e3bd5c9e780d51f7986a4408 (diff) | |
| parent | 98096a96c80e5488ebc0da51676835e434a751ab (diff) | |
| download | rust-17ea490310ba7c836c93fe1b7002555b3bea5eb1.tar.gz rust-17ea490310ba7c836c93fe1b7002555b3bea5eb1.zip | |
Auto merge of #82624 - ojeda:rwlock-example-deadlock, r=JohnTitor
RWLock: Add deadlock example Suggested in https://github.com/rust-lang/rust/pull/82596 but it was a bit too late. `@matklad` `@azdavis` `@sfackler`
| -rw-r--r-- | library/std/src/sync/rwlock.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 0d00f74eaa1..e50d62d8173 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -23,7 +23,19 @@ use crate::sys_common::rwlock as sys; /// system's implementation, and this type does not guarantee that any /// particular policy will be used. In particular, a writer which is waiting to /// acquire the lock in `write` might or might not block concurrent calls to -/// `read`. +/// `read`, e.g.: +/// +/// <details><summary>Potential deadlock example</summary> +/// +/// ```text +/// // Thread 1 | // Thread 2 +/// let _rg = lock.read(); | +/// | // will block +/// | let _wg = lock.write(); +/// // may deadlock | +/// let _rg = lock.read(); | +/// ``` +/// </details> /// /// The type parameter `T` represents the data that this lock protects. It is /// required that `T` satisfies [`Send`] to be shared across threads and |
