This post from @alice might be of interest too.
Also see the Tokio Tutorial chapter on Shared state. Note that ironically std::sync::Mutex
std::sync::MutexGuard
isn't Send
, but tokio::sync::Mutex
tokio::sync::MutexGuard
is Send
.
(Edit: Corrected the mistake)
In some cases, it may make sense to use the mutex from std::sync
, in other cases it is important to use an async-aware mutex.