r2d2 icon indicating copy to clipboard operation
r2d2 copied to clipboard

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

Open antoyo opened this issue 2 years ago • 3 comments

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

antoyo avatar Dec 31 '22 01:12 antoyo

Why?

parking_lot also avoids the poisoning behavior.

sfackler avatar Dec 31 '22 01:12 sfackler

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.

antoyo avatar Dec 31 '22 01:12 antoyo

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)
    }
}

BratSinot avatar Feb 20 '23 10:02 BratSinot