Skip to content

Commit

Permalink
perf(host): release running_tasks lock asap (#417)
Browse files Browse the repository at this point in the history
Co-authored-by: smtmfft <[email protected]>
  • Loading branch information
keroro520 and smtmfft authored Nov 22, 2024
1 parent bd7bf99 commit 6e98484
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ impl ProofActor {
}

pub async fn cancel_task(&mut self, key: ProofTaskDescriptor) -> HostResult<()> {
let tasks_map = self.running_tasks.lock().await;
let Some(task) = tasks_map.get(&key) else {
warn!("No task with those keys to cancel");
return Ok(());
let task = {
let tasks_map = self.running_tasks.lock().await;
match tasks_map.get(&key) {
Some(task) => task.to_owned(),
None => {
warn!("No task with those keys to cancel");
return Ok(());
}
}
};

let mut manager = get_task_manager(&self.opts.clone().into());
Expand Down Expand Up @@ -134,10 +139,12 @@ impl ProofActor {
proof_request.prover.clone().to_string(),
));

let mut tasks = self.running_tasks.lock().await;
tasks.insert(key.clone(), cancel_token.clone());
let sender = self.sender.clone();
{
let mut tasks = self.running_tasks.lock().await;
tasks.insert(key.clone(), cancel_token.clone());
}

let sender = self.sender.clone();
let tasks = self.running_tasks.clone();
let opts = self.opts.clone();
let chain_specs = self.chain_specs.clone();
Expand Down

0 comments on commit 6e98484

Please sign in to comment.