pub struct TaskSupervisor { /* private fields */ }Expand description
Owns named background tasks tied to one ShutdownToken.
Implementations§
Source§impl TaskSupervisor
impl TaskSupervisor
Sourcepub fn new(shutdown: ShutdownToken) -> Self
pub fn new(shutdown: ShutdownToken) -> Self
Creates an empty task supervisor.
Sourcepub fn spawn<F, Fut>(
&mut self,
name: impl Into<String>,
policy: RestartPolicy,
factory: F,
)
pub fn spawn<F, Fut>( &mut self, name: impl Into<String>, policy: RestartPolicy, factory: F, )
Spawns a named task from a restartable future factory.
Both a normal return and a panic are unexpected before shutdown. The
selected policy either restarts the factory or triggers process shutdown.
Sourcepub async fn join(self) -> Result<(), DrainTimeout>
pub async fn join(self) -> Result<(), DrainTimeout>
Waits for shutdown and joins all supervised tasks within its drain deadline.
Any tasks still alive when the deadline expires are aborted before this
method returns DrainTimeout.
Auto Trait Implementations§
impl !RefUnwindSafe for TaskSupervisor
impl !UnwindSafe for TaskSupervisor
impl Freeze for TaskSupervisor
impl Send for TaskSupervisor
impl Sync for TaskSupervisor
impl Unpin for TaskSupervisor
impl UnsafeUnpin for TaskSupervisor
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