From 71b6d5ca2076e14d81288179262c4ad227de8a8f Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sun, 24 Mar 2024 12:07:37 +0000 Subject: [PATCH] Link more consistently to stdlib on mutex page --- src/concurrency/shared-state/mutex.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/concurrency/shared-state/mutex.md b/src/concurrency/shared-state/mutex.md index 57721a18..6cefc9da 100644 --- a/src/concurrency/shared-state/mutex.md +++ b/src/concurrency/shared-state/mutex.md @@ -4,8 +4,8 @@ minutes: 14 # `Mutex` -[`Mutex`][1] ensures mutual exclusion _and_ allows mutable access to `T` -behind a read-only interface (another form of +[`Mutex`] ensures mutual exclusion _and_ allows mutable access to `T` behind +a read-only interface (another form of [interior mutability](../../borrowing/interior-mutability.md)): ```rust,editable @@ -27,9 +27,7 @@ fn main() { Notice how we have a [`impl Sync for Mutex`][2] blanket implementation. -[1]: https://doc.rust-lang.org/std/sync/struct.Mutex.html [2]: https://doc.rust-lang.org/std/sync/struct.Mutex.html#impl-Sync-for-Mutex%3CT%3E -[3]: https://doc.rust-lang.org/std/sync/struct.Arc.html
@@ -41,13 +39,15 @@ implementation. `MutexGuard` ensures that the `&mut T` doesn't outlive the lock being held. - `Mutex` implements both `Send` and `Sync` iff (if and only if) `T` implements `Send`. -- A read-write lock counterpart: `RwLock`. +- Rust has a multi-reader single-writer lock counterpart: [`RwLock`]. - Why does `lock()` return a `Result`? - If the thread that held the `Mutex` panicked, the `Mutex` becomes "poisoned" to signal that the data it protected might be in an inconsistent state. Calling `lock()` on a poisoned mutex fails with a [`PoisonError`]. You can call `into_inner()` on the error to recover the data regardless. -[`PoisonError`]: https://doc.rust-lang.org/std/sync/struct.PoisonError.html -
+ +[`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html +[`RwLock`]: https://doc.rust-lang.org/std/sync/struct.RwLock.html +[`PoisonError`]: https://doc.rust-lang.org/std/sync/struct.PoisonError.html