Skip to content

Commit

Permalink
fix: not panic in destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangli-pear committed Jan 6, 2020
1 parent 8f69413 commit 2afab63
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/src/parking_lot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,10 +1198,9 @@ mod deadlock_impl {
pub unsafe fn release_resource(key: usize) {
with_thread_data(|thread_data| {
let resources = &mut (*thread_data.deadlock_data.resources.get());
match resources.iter().rposition(|x| *x == key) {
Some(p) => resources.swap_remove(p),
None => panic!("key {} not found in thread resources", key),
};
if let Some(p) = resources.iter().rposition(|x| *x == key) {
resources.swap_remove(p);
}
});
}

Expand Down

0 comments on commit 2afab63

Please sign in to comment.