#[inline(always)]
fn deref(&self) -> &T {
- &*self.0
+ &self.0
}
}
#[cfg(parallel_compiler)]
#[inline(always)]
+ #[track_caller]
pub fn lock(&self) -> LockGuard<'_, T> {
if ERROR_CHECKING {
self.0.try_lock().expect("lock was already held")
#[cfg(not(parallel_compiler))]
#[inline(always)]
+ #[track_caller]
pub fn lock(&self) -> LockGuard<'_, T> {
self.0.borrow_mut()
}
#[inline(always)]
+ #[track_caller]
pub fn with_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
f(&mut *self.lock())
}
#[inline(always)]
+ #[track_caller]
pub fn borrow(&self) -> LockGuard<'_, T> {
self.lock()
}
#[inline(always)]
+ #[track_caller]
pub fn borrow_mut(&self) -> LockGuard<'_, T> {
self.lock()
}
#[cfg(not(parallel_compiler))]
#[inline(always)]
+ #[track_caller]
pub fn read(&self) -> ReadGuard<'_, T> {
self.0.borrow()
}
}
#[inline(always)]
+ #[track_caller]
pub fn with_read_lock<F: FnOnce(&T) -> R, R>(&self, f: F) -> R {
f(&*self.read())
}
#[cfg(not(parallel_compiler))]
#[inline(always)]
+ #[track_caller]
pub fn write(&self) -> WriteGuard<'_, T> {
self.0.borrow_mut()
}
}
#[inline(always)]
+ #[track_caller]
pub fn with_write_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
f(&mut *self.write())
}
#[inline(always)]
+ #[track_caller]
pub fn borrow(&self) -> ReadGuard<'_, T> {
self.read()
}
#[inline(always)]
+ #[track_caller]
pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
self.write()
}