#[cfg(feature = "loom")]
pub(crate) use loom::sync::{Condvar, Mutex, MutexGuard};

#[cfg(all(feature = "parking_lot", not(feature = "loom")))]
pub(crate) use parking_lot::{Condvar, Mutex, MutexGuard};

#[cfg(not(any(feature = "parking_lot", feature = "loom")))]
pub(crate) use std::sync::{Condvar, Mutex, MutexGuard};

#[cfg(feature = "loom")]
#[inline(always)]
pub(crate) fn lock<T>(mutex: &Mutex<T>) -> MutexGuard<'_, T> {
    mutex.lock().expect("loom mutex poisoned")
}

#[cfg(all(feature = "parking_lot", not(feature = "loom")))]
#[inline(always)]
pub(crate) fn lock<T>(mutex: &Mutex<T>) -> MutexGuard<'_, T> {
    mutex.lock()
}

#[cfg(not(any(feature = "parking_lot", feature = "loom")))]
#[inline(always)]
pub(crate) fn lock<T>(mutex: &Mutex<T>) -> MutexGuard<'_, T> {
    mutex.lock().expect("mutex poisoned")
}
