pub struct BackgroundTasks { /* private fields */ }Expand description
Shutdown-aware collection of spawned background workers.
Implementations§
Source§impl BackgroundTasks
impl BackgroundTasks
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a task collection with a fresh shutdown token and the default shutdown grace.
Sourcepub fn with_shutdown_token(shutdown_token: CancellationToken) -> Self
pub fn with_shutdown_token(shutdown_token: CancellationToken) -> Self
Creates a task collection using an externally owned shutdown token.
Sourcepub fn with_shutdown_token_and_grace(
shutdown_token: CancellationToken,
shutdown_grace: Duration,
) -> Self
pub fn with_shutdown_token_and_grace( shutdown_token: CancellationToken, shutdown_grace: Duration, ) -> Self
Creates a task collection using an externally owned token and custom shutdown grace.
Sourcepub fn shutdown_token(&self) -> CancellationToken
pub fn shutdown_token(&self) -> CancellationToken
Returns a clone of the shutdown token observed by all workers in this collection.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BackgroundTasks
impl !RefUnwindSafe for BackgroundTasks
impl Send for BackgroundTasks
impl Sync for BackgroundTasks
impl Unpin for BackgroundTasks
impl UnsafeUnpin for BackgroundTasks
impl !UnwindSafe for BackgroundTasks
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