Skip to content

Commit

Permalink
Unbury the lede on tokio::sync::mutex docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Sep 4, 2024
1 parent 1166ecc commit a8d456b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tokio/src/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ use std::{fmt, mem, ptr};
///
/// # Which kind of mutex should you use?
///
/// Contrary to popular belief, it is ok and often preferred to use the ordinary
/// [`Mutex`][std] from the standard library in asynchronous code.
/// The ordinary std [`Mutex`][std] cannot be held across an `.await` point -
/// your program will deadlock if you do this. Use the async mutex instead in
/// such cases. However, it is ok and often preferred to use the std mutex in
/// asynchronous tasks when it does not need to be held across an `.await`
/// point.
///
/// The feature that the async mutex offers over the blocking mutex is the
/// ability to keep it locked across an `.await` point. This makes the async
Expand Down

0 comments on commit a8d456b

Please sign in to comment.