pub struct ShutdownController { /* private fields */ }Expand description
Permits to keep track of ongoing tasks, ask them to shutdown and wait for all of them to quit.
Stupid wrapper around tokio_util::sync::CancellationToken and tokio_util::task::task_tracker::TaskTracker.
Implementations§
Source§impl ShutdownController
impl ShutdownController
pub fn new() -> Self
Sourcepub fn ask_shutdown(&self)
pub fn ask_shutdown(&self)
Ask for all tasks to quit
Sourcepub async fn wait_all_task_shutdown(self)
pub async fn wait_all_task_shutdown(self)
Wait for all tasks to quit.
This task may return even without having called ShutdownController::ask_shutdown
first, if all tasks quit by themselves.
Sourcepub fn token(&self) -> ShutdownToken
pub fn token(&self) -> ShutdownToken
Returns a new shutdown token, to be held by a task.
Sourcepub fn delegate(&self) -> ShutdownDelegate
pub fn delegate(&self) -> ShutdownDelegate
Returns a ShutdownDelegate, which is able to ask for shutdown,
without counting as a task that needs to be awaited.
Sourcepub fn wait(&self) -> WaitForCancellationFuture<'_>
pub fn wait(&self) -> WaitForCancellationFuture<'_>
Returns a future that will resolve only when a shutdown request happened.
Trait Implementations§
Source§impl Clone for ShutdownController
impl Clone for ShutdownController
Source§fn clone(&self) -> ShutdownController
fn clone(&self) -> ShutdownController
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ShutdownController
impl Default for ShutdownController
Source§fn default() -> ShutdownController
fn default() -> ShutdownController
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ShutdownController
impl RefUnwindSafe for ShutdownController
impl Send for ShutdownController
impl Sync for ShutdownController
impl Unpin for ShutdownController
impl UnwindSafe for ShutdownController
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