#[must_use = "if unused the Mutex will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct MutexGuard<'a, T: ?Sized + 'a> {
- // funny underscores due to how Deref/DerefMut currently work (they
- // disregard field privacy).
- __lock: &'a Mutex<T>,
- __poison: poison::Guard,
+ lock: &'a Mutex<T>,
+ poison: poison::Guard,
}
#[stable(feature = "rust1", since = "1.0.0")]
unsafe fn new(lock: &'mutex Mutex<T>) -> LockResult<MutexGuard<'mutex, T>> {
poison::map_result(lock.poison.borrow(), |guard| {
MutexGuard {
- __lock: lock,
- __poison: guard,
+ lock: lock,
+ poison: guard,
}
})
}
type Target = T;
fn deref(&self) -> &T {
- unsafe { &*self.__lock.data.get() }
+ unsafe { &*self.lock.data.get() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut T {
- unsafe { &mut *self.__lock.data.get() }
+ unsafe { &mut *self.lock.data.get() }
}
}
#[inline]
fn drop(&mut self) {
unsafe {
- self.__lock.poison.done(&self.__poison);
- self.__lock.inner.raw_unlock();
+ self.lock.poison.done(&self.poison);
+ self.lock.inner.raw_unlock();
}
}
}
}
pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex {
- &guard.__lock.inner
+ &guard.lock.inner
}
pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Flag {
- &guard.__lock.poison
+ &guard.lock.poison
}
#[cfg(all(test, not(target_os = "emscripten")))]
#[must_use = "if unused the RwLock will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
- __lock: &'a RwLock<T>,
+ lock: &'a RwLock<T>,
}
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use = "if unused the RwLock will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
- __lock: &'a RwLock<T>,
- __poison: poison::Guard,
+ lock: &'a RwLock<T>,
+ poison: poison::Guard,
}
#[stable(feature = "rust1", since = "1.0.0")]
-> LockResult<RwLockReadGuard<'rwlock, T>> {
poison::map_result(lock.poison.borrow(), |_| {
RwLockReadGuard {
- __lock: lock,
+ lock: lock,
}
})
}
-> LockResult<RwLockWriteGuard<'rwlock, T>> {
poison::map_result(lock.poison.borrow(), |guard| {
RwLockWriteGuard {
- __lock: lock,
- __poison: guard,
+ lock: lock,
+ poison: guard,
}
})
}
impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwLockReadGuard")
- .field("lock", &self.__lock)
+ .field("lock", &self.lock)
.finish()
}
}
impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwLockWriteGuard")
- .field("lock", &self.__lock)
+ .field("lock", &self.lock)
.finish()
}
}
type Target = T;
fn deref(&self) -> &T {
- unsafe { &*self.__lock.data.get() }
+ unsafe { &*self.lock.data.get() }
}
}
type Target = T;
fn deref(&self) -> &T {
- unsafe { &*self.__lock.data.get() }
+ unsafe { &*self.lock.data.get() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> DerefMut for RwLockWriteGuard<'_, T> {
fn deref_mut(&mut self) -> &mut T {
- unsafe { &mut *self.__lock.data.get() }
+ unsafe { &mut *self.lock.data.get() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for RwLockReadGuard<'_, T> {
fn drop(&mut self) {
- unsafe { self.__lock.inner.read_unlock(); }
+ unsafe { self.lock.inner.read_unlock(); }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for RwLockWriteGuard<'_, T> {
fn drop(&mut self) {
- self.__lock.poison.done(&self.__poison);
- unsafe { self.__lock.inner.write_unlock(); }
+ self.lock.poison.done(&self.poison);
+ unsafe { self.lock.inner.write_unlock(); }
}
}