pub struct CancellationGroup { /* private fields */ }Expand description
A cancellation control handle shared by a group of operations.
Cancelling a parent group prevents all descendants from admitting further
operations; cancelling a child does not affect its parent or sibling groups.
Dropping this handle only releases a reference. Use
Self::cancel_on_drop to cancel when a guard is dropped.
Implementations§
Source§impl CancellationGroup
impl CancellationGroup
Sourcepub fn child(&self) -> Self
pub fn child(&self) -> Self
Creates a child group whose cancellation is independent unless the parent is cancelled.
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Irreversibly close admission, then wake waiters outside internal locks. This needs no runtime and does not wait for network or callback cleanup.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns whether cancellation has been requested for this group or an ancestor.
Sourcepub async fn cancelled(&self)
pub async fn cancelled(&self)
Wait for cancellation without creating a worker or requiring a runtime.
Sourcepub fn cancel_on_drop(&self) -> CancellationGuard
pub fn cancel_on_drop(&self) -> CancellationGuard
Returns a guard that cancels this group when dropped unless disarmed.