use std::ops::{Deref, DerefMut};
#[derive(Debug)]
pub(crate) struct Mutex<T> {
inner: parking_lot::Mutex<T>,
}
impl<T> Mutex<T> {
pub(crate) fn new(value: T) -> Self {
Self {
inner: parking_lot::Mutex::new(value),
}
}
pub(crate) fn lock(&self, purpose: &'static str) -> MutexGuard<'_, T> {
let _ = purpose;
MutexGuard {
guard: self.inner.lock(),
}
}
}
pub(crate) struct MutexGuard<'a, T> {
guard: parking_lot::MutexGuard<'a, T>,
}
impl<T> Deref for MutexGuard<'_, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
self.guard.deref()
}
}
impl<T> DerefMut for MutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.guard.deref_mut()
}
}