Skip to content

Commit

Permalink
Auto merge of rust-lang#82624 - ojeda:rwlock-example-deadlock, r=John…
Browse files Browse the repository at this point in the history
…Titor

RWLock: Add deadlock example

Suggested in rust-lang#82596 but it was a bit too late.

`@matklad` `@azdavis` `@sfackler`
  • Loading branch information
bors committed Jun 28, 2021
2 parents 451e98e + 98096a9 commit 17ea490
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion library/std/src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17ea490

Please sign in to comment.