pub struct SupervisorHandle { /* private fields */ }Expand description
Controls a running supervisor. Cheap to clone.
Dropping the last handle shuts the supervisor down gracefully.
Implementations§
Source§impl SupervisorHandle
impl SupervisorHandle
Sourcepub async fn add_task(
&self,
name: &str,
task: impl SupervisedTask,
) -> Result<(), SupervisorHandleError>
pub async fn add_task( &self, name: &str, task: impl SupervisedTask, ) -> Result<(), SupervisorHandleError>
Registers and starts a task. Returns once it is
Running.
Sourcepub async fn restart_task(
&self,
name: &str,
) -> Result<(), SupervisorHandleError>
pub async fn restart_task( &self, name: &str, ) -> Result<(), SupervisorHandleError>
Sourcepub async fn kill_task(&self, name: &str) -> Result<(), SupervisorHandleError>
pub async fn kill_task(&self, name: &str) -> Result<(), SupervisorHandleError>
Stops a task permanently and returns once it is
Dead, which takes at most stop_timeout.
Idempotent.
Sourcepub async fn task_status(
&self,
name: &str,
) -> Result<TaskStatus, SupervisorHandleError>
pub async fn task_status( &self, name: &str, ) -> Result<TaskStatus, SupervisorHandleError>
Current status of one task.
Sourcepub async fn task_statuses(
&self,
) -> Result<HashMap<Arc<str>, TaskStatus>, SupervisorHandleError>
pub async fn task_statuses( &self, ) -> Result<HashMap<Arc<str>, TaskStatus>, SupervisorHandleError>
Current status of every task, keyed by name.
Sourcepub async fn shutdown(&self) -> Result<(), SupervisorError>
pub async fn shutdown(&self) -> Result<(), SupervisorError>
Cancels every task, waits for them to exit (bounded by stop_timeout)
and returns the supervisor outcome. Same as wait if the
supervisor already exited.
Sourcepub async fn wait(&self) -> Result<(), SupervisorError>
pub async fn wait(&self) -> Result<(), SupervisorError>
Waits for the supervisor to exit. Can be awaited any number of times, from any clone.
Trait Implementations§
Source§impl Clone for SupervisorHandle
impl Clone for SupervisorHandle
Auto Trait Implementations§
impl Freeze for SupervisorHandle
impl RefUnwindSafe for SupervisorHandle
impl Send for SupervisorHandle
impl Sync for SupervisorHandle
impl Unpin for SupervisorHandle
impl UnsafeUnpin for SupervisorHandle
impl UnwindSafe for SupervisorHandle
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