Skip to content

Commit

Permalink
- added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Jan 31, 2024
1 parent c826021 commit 4a350d7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commons/zenoh-task/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ impl TaskController {
running_task_id_to_handle: Arc::new(Mutex::new(HashMap::<Uuid, Option<JoinHandle<()>>>::new()))
}
}

/// Spawns a task (similarly to task::spawn) that can be later terminated by call to terminate_all()
/// Task output is ignored
pub fn spawn<F, T>(&self, future: F)
where
F: Future<Output = T> + Send + 'static,
Expand Down Expand Up @@ -68,6 +71,7 @@ impl TaskController {
}
}

/// Terminates all prevously spawned tasks
pub fn terminate_all(&self) {
let tasks: Vec<(Uuid, Option<JoinHandle<()>>)> = self.running_task_id_to_handle.lock().unwrap().drain().collect();
for (_id, jh) in tasks {
Expand Down

0 comments on commit 4a350d7

Please sign in to comment.