Skip to content

Commit

Permalink
fix: avoid deadlocking if can't take Memo write lock (closes #3158) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored Oct 25, 2024
1 parent 396327b commit d306a15
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions reactive_graph/src/computed/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ where

changed
} else {
let mut lock = self.write().or_poisoned();
lock.state = ReactiveNodeState::Clean;
if let Ok(mut lock) = self.try_write() {
lock.state = ReactiveNodeState::Clean;
}
false
}
}
Expand All @@ -142,7 +143,9 @@ where
S: Storage<T>,
{
fn add_subscriber(&self, subscriber: AnySubscriber) {
self.write().or_poisoned().subscribers.subscribe(subscriber);
if let Ok(mut lock) = self.try_write() {
lock.subscribers.subscribe(subscriber);
}
}

fn remove_subscriber(&self, subscriber: &AnySubscriber) {
Expand Down

0 comments on commit d306a15

Please sign in to comment.