Inspect and adjust mutex usage in all crates
When I was first programming Arti, I didn't fully understand the difference between futures::lock::Mutex
and std::sync::Mutex
. In particular, I believed that I used the futures-aware mutex in a lot of places where it wasn't necessary.
(The practical difference, as I now understand it, is that you need to use futures::lock::Mutex
anywhere that you might await
when holding a lock. It is okay to use the regular std::sync::Mutex
, even in an async
function so long as you never await
while holding the lock. The contemplated Rust must_not_await
feature will make correct usage easier to enforce here.)
It would be a good idea for someone to have a careful look at everyplace in our code that uses either Mutex
, and see if it needs to be replaced with the other.