Skip to content

Commit

Permalink
remove from map
Browse files Browse the repository at this point in the history
Signed-off-by: Yashash H L <[email protected]>
  • Loading branch information
yhl25 committed May 30, 2024
1 parent 9989e5b commit aa3da61
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,15 @@ where
}

/// Closes all tasks in the task manager and sends an EOF message to the response stream.
// Method to close all tasks
async fn close_all_tasks(&mut self) {
for task in self.tasks..values_mut() {
task.close().await;
let task_keys: Vec<_> = self.tasks.keys().cloned().collect();
for task_key in task_keys {
if let Some(task) = self.tasks.remove(&task_key) {
// drop the sender to close the task
drop(task.tx);
// wait for the task to finish
task.handle.await.unwrap();
}
}

// after all the tasks have been closed, send an EOF message to the response stream
Expand Down

0 comments on commit aa3da61

Please sign in to comment.