panic if RwLock is poisoned

This commit is contained in:
2022-06-21 00:44:34 +00:00
committed by GitHub
parent f58739c954
commit 21e2279209

View File

@@ -14,6 +14,9 @@ impl<T: Sized> GetRwLock for RwLock<T> {
type Target = T;
fn get_ref<'a>(&'a self) -> RwLockReadGuard<'a, Self::Target> {
loop {
if self.is_poisoned() {
panic!("Target is poisoned.");
}
match self.try_read() {
Ok(f) => {
return f;
@@ -26,6 +29,9 @@ impl<T: Sized> GetRwLock for RwLock<T> {
}
fn get_mut<'a>(&'a self) -> RwLockWriteGuard<'a, Self::Target> {
loop {
if self.is_poisoned() {
panic!("Target is poisoned.");
}
match self.try_write() {
Ok(f) => {
return f;