pub struct TaskManager { /* private fields */ }Expand description
Manages a collection of spawned tokio tasks.
This struct provides a centralized way to spawn, track, and manage the lifecycle of async tasks in the translator. It maintains a list of join handles that can be used to wait for all tasks to complete or abort them during shutdown.
Implementations§
Source§impl TaskManager
impl TaskManager
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new TaskManager instance.
Initializes an empty task manager ready to spawn and track tasks.
Sourcepub fn spawn<F>(&self, fut: F)
pub fn spawn<F>(&self, fut: F)
Spawns a new async task and adds it to the managed collection.
The task will be tracked by this manager and can be waited for or aborted using the other methods.
§Arguments
fut- The future to spawn as a task
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TaskManager
impl RefUnwindSafe for TaskManager
impl Send for TaskManager
impl Sync for TaskManager
impl Unpin for TaskManager
impl UnwindSafe for TaskManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more