Skip to content

Commit

Permalink
Fix recursively acquire mutex error in invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanboere committed Dec 7, 2024
1 parent 439d75b commit 4ea3322
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions query/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,18 @@ where
&self,
update_fn: impl FnOnce(QueryState<V>) -> Result<QueryState<V>, QueryState<V>>,
) -> bool {
let mut self_state = self.state.lock().unwrap();
let current_state = self_state.clone();
let current_state = {
let mut self_state = self.state.lock().unwrap();
self_state.clone()
};

match update_fn(current_state) {
Ok(new_state) => {
self.set_state(new_state);
true
}
Err(old_state) => {
let mut self_state = self.state.lock().unwrap();
*self_state = old_state;
false
}
Expand Down

0 comments on commit 4ea3322

Please sign in to comment.