Poisoned mutex strategies

.unwrap() on lock() errors in library crates? Yay or nay?

parking_lot::Mutex doesn't have poisoned state. Why don't you use it instead?

1 Like

If you genuinely expect the program to continue after panics (e.g. because it's a multi-threaded server and uptime is crucial), and you have a strategy to actually recover (e.g. the lock guards a cache, and you can rebuild the cache), then you could try handling the error. Otherwise, unwrap() is fine.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.