-
-
Notifications
You must be signed in to change notification settings - Fork 407
[All] Mutex performance improvement: asynchronous mutex vs synchronous mutex #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For example, don't use std::sync::Mutex or parking_lot::Mutex on the following case, which hold the lock across the .await point.
|
it is ok to use std::sync::Mutex or parking_lot::Mutex when it is not across the .await point, for example:
|
It also kinda depends on what thread is being locked. Locking runtime's (tokio/async-std) threads might result in whole system performance degradation, since locking runtime's threads would prevent them from driving other tasks (like i/o) or even disrupt the whole cooperative scheduling. Blocking operations are usually offloaded on a separate threads (spawn_blocking) |
Tokio's docs recommend using
|
tokio::sync::Mutex vs std::sync::Mutex vs parking_lot::Mutex
change tokio::sync::Mutex to std::sync::Mutex or parking_lot::Mutex when it is not across .await
The text was updated successfully, but these errors were encountered: