Change clear_poison to take the lock instead of a guard
This commit is contained in:
parent
f7ac8e7aef
commit
66d88c9a18
@ -387,14 +387,19 @@ impl<T: ?Sized> Mutex<T> {
|
|||||||
/// panic!(); // the mutex gets poisoned
|
/// panic!(); // the mutex gets poisoned
|
||||||
/// }).join();
|
/// }).join();
|
||||||
///
|
///
|
||||||
/// let guard = mutex.lock().unwrap_err().into_inner();
|
/// assert_eq!(mutex.is_poisoned(), true);
|
||||||
/// Mutex::clear_poison(&guard);
|
/// let x = mutex.lock().unwrap_or_else(|mut e| {
|
||||||
|
/// **e.get_mut() = 1;
|
||||||
|
/// mutex.clear_poison();
|
||||||
|
/// e.into_inner()
|
||||||
|
/// });
|
||||||
/// assert_eq!(mutex.is_poisoned(), false);
|
/// assert_eq!(mutex.is_poisoned(), false);
|
||||||
|
/// assert_eq!(*x, 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "mutex_unpoison", issue = "96469")]
|
#[unstable(feature = "mutex_unpoison", issue = "96469")]
|
||||||
pub fn clear_poison(guard: &MutexGuard<'_, T>) {
|
pub fn clear_poison(&self) {
|
||||||
guard.lock.poison.clear();
|
self.poison.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes this mutex, returning the underlying data.
|
/// Consumes this mutex, returning the underlying data.
|
||||||
|
@ -390,14 +390,19 @@ impl<T: ?Sized> RwLock<T> {
|
|||||||
/// panic!(); // the mutex gets poisoned
|
/// panic!(); // the mutex gets poisoned
|
||||||
/// }).join();
|
/// }).join();
|
||||||
///
|
///
|
||||||
/// let guard = lock.write().unwrap_err().into_inner();
|
/// assert_eq!(lock.is_poisoned(), true);
|
||||||
/// RwLock::clear_poison(&guard);
|
/// let guard = lock.write().unwrap_or_else(|mut e| {
|
||||||
|
/// **e.get_mut() = 1;
|
||||||
|
/// lock.clear_poison();
|
||||||
|
/// e.into_inner()
|
||||||
|
/// });
|
||||||
/// assert_eq!(lock.is_poisoned(), false);
|
/// assert_eq!(lock.is_poisoned(), false);
|
||||||
|
/// assert_eq!(*guard, 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "mutex_unpoison", issue = "96469")]
|
#[unstable(feature = "mutex_unpoison", issue = "96469")]
|
||||||
pub fn clear_poison(guard: &RwLockWriteGuard<'_, T>) {
|
pub fn clear_poison(&self) {
|
||||||
guard.lock.poison.clear();
|
self.poison.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes this `RwLock`, returning the underlying data.
|
/// Consumes this `RwLock`, returning the underlying data.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user