pub struct CancelTaskSet {
pub join_set: JoinSet<Result<(), Error>>,
/* private fields */
}Expand description
A combination of a tokio::task::JoinSet and tokio_util::sync::CancellationToken.
Provides methods that are commonly used in conjunction with those two data structures.
Fields§
§join_set: JoinSet<Result<(), Error>>Task set join set.
Implementations§
Source§impl CancelTaskSet
impl CancelTaskSet
Sourcepub fn new_with_signal_handler() -> Self
pub fn new_with_signal_handler() -> Self
Creates a task set and registers a signal handler that calls cancel()
on the cancellation token upon receiving SIGINT and SIGTERM.
Sourcepub fn from_cancel_token(
register_signal_handler: bool,
cancellation_token: CancellationToken,
) -> Self
pub fn from_cancel_token( register_signal_handler: bool, cancellation_token: CancellationToken, ) -> Self
Creates a task set from an existing cancellation token.
§Arguments
register_signal_handler: If true, a signal handler is registered that callscancel()on the cancellation token upon receivingSIGINTandSIGTERM.cancellation_token: The cancellation token to use.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Returns a clone of the cancellation token.
Sourcepub fn spawn_cancellable_task<Fut>(&mut self, task: Fut)
pub fn spawn_cancellable_task<Fut>(&mut self, task: Fut)
Spawns a task that will run until it is cancelled or completes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CancelTaskSet
impl !RefUnwindSafe for CancelTaskSet
impl Send for CancelTaskSet
impl Sync for CancelTaskSet
impl Unpin for CancelTaskSet
impl !UnwindSafe for CancelTaskSet
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