Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions content/tokio/tutorial/shared-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ from within async code. An async mutex is a mutex that is locked across calls
to `.await`.

A synchronous mutex will block the current thread when waiting to acquire the
lock. This, in turn, will block other tasks from processing. However, switching
to `tokio::sync::Mutex` usually does not help as the asynchronous mutex uses a
synchronous mutex internally.
lock. This, in turn, will block other tasks from processing. Switching
to `tokio::sync::Mutex` will cause the task to yield control back to the
executor, but this will usually not help with performance as the asynchronous
mutex uses a synchronous mutex internally.

As a rule of thumb, using a synchronous mutex from within asynchronous code is
fine as long as contention remains low and the lock is not held across calls to
Expand Down