Unpoisoning a Mutex

A method on MutexGuard seems more reasonable since that gives you the ability to inspect the data before deciding whether to unpoison it. You could probably just go ahead and PR this. It's pretty trivial to implement:

// in sync/poison.rs
impl Flag {
    pub fn unpoison(&self, _guard: &Guard) {
        self.failed.store(false, Ordering::Relaxed);
    }
}

// in sync/mutex.rs
impl<'a, T> MutexGuard<'a, T> {
    fn unpoison(guard: &mut MutexGuard<'a, T>) {
        self.lock.poison.unpoison(&self.poison);
    }
}
4 Likes