fix deadlock

This commit is contained in:
Evan Almloff committed 2023-02-01 14:15:17 -06:00
1 parent 5eb4ca677d
commit 39a3db68bd
1 file changed
+12 -5
+12 -5
View File
@@ -1,4 +1,5 @@
use anymap::AnyMap;
use core::panic;
use parking_lot::RwLock;
use rustc_hash::FxHashSet;
use std::any::{Any, TypeId};
@@ -80,6 +81,7 @@ impl DirtyNodeStates {
let mut dirty = values.get_mut(&pass_id)?;
let node_id = dirty.pop()?;
if dirty.is_empty() {
drop(dirty);
values.remove(&pass_id);
}
node_id
@@ -99,12 +101,17 @@ impl DirtyNodeStates {
.iter()
.rev()
.find(|(_, values)| values.contains_key(&pass_id))?;
let mut dirty = values.get_mut(&pass_id)?;
let node_id = dirty.pop()?;
if dirty.is_empty() {
values.remove(&pass_id);
}
let node_id = {
let mut dirty = values.get_mut(&pass_id)?;
let node_id = dirty.pop()?;
if dirty.is_empty() {
drop(dirty);
values.remove(&pass_id);
}
node_id
};
if values.is_empty() {
drop(dirty_read);
let mut dirty_write = self.dirty.write();
dirty_write.remove(&height);
}