sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.51k stars 82 forks source link

Remove parking_lot dependency now that std's Mutex is faster than before #138

Open antoyo opened 1 year ago

antoyo commented 1 year ago

Hi. Do you think we could remove the dependency to parking_lot now that std's Mutex is faster than before? Regards.

sfackler commented 1 year ago

Why?

parking_lot also avoids the poisoning behavior.

antoyo commented 1 year ago

Oh, I thought it was used for performance reasons. So, removing it would reduce the build time.

But if it was used to avoid this behavior, then I guess there's no reason to remove it.

BratSinot commented 1 year ago

parking_lot also avoids the poisoning behavior.

You can get same behaviour by simple wrapper:

struct Mutex<T>(std::sync::Mutex<T>);

impl<T> Mutex<T> {
    pub fn lock(&self) -> std::sync::MutexGuard<T> {
        self.0.lock().unwrap_or_else(PoisonError::into_inner)
    }
}