WebAssembly / wasi-crypto

WASI Cryptography API Proposal
162 stars 25 forks source link

Replace `parking_lot` with `std::sync::Mutex`. #60

Closed sunfishcode closed 2 years ago

sunfishcode commented 2 years ago

As of Rust 1.62, std::sync::Mutex is much faster and doesn't require dynamic allocation.

Also, it supports poisoning (see the added .unwrap() calls), which means that if one thread panics while holding a locked mutex, other threads trying to unlock the mutex will also panic, rather than silently acquiring the lock. This gives applications a better chance of safely shutting down in the event of a panic.

jedisct1 commented 2 years ago

Thank you!

A convenient feature of parking_lot was its ability to easily trace dead locks. Is it something that can also be done with std::sync::Mutex?

sunfishcode commented 2 years ago

Unfortunately no, I don't believe std::sync::Mutex has that feature.