pub struct TaskGroup { /* private fields */ }Expand description
Owns a related group of cancellation-aware live tasks, one generation at a time.
Call Self::finish_shutdown to observe task failures. Dropping the group requests forced
cancellation but cannot asynchronously prove termination.
Implementations§
Source§impl TaskGroup
impl TaskGroup
Sourcepub fn spawner(&self) -> Result<TaskSpawner, TaskSpawnError>
pub fn spawner(&self) -> Result<TaskSpawner, TaskSpawnError>
Returns a capability bound to the current open generation.
§Errors
Returns an error after shutdown begins.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Returns a non-authoritative cancellation signal for the current generation.
Sourcepub fn spawn<F>(&self, future: F) -> Result<(), TaskSpawnError>
pub fn spawn<F>(&self, future: F) -> Result<(), TaskSpawnError>
Sourcepub fn begin_shutdown(&self)
pub fn begin_shutdown(&self)
Closes admission and cancels the current generation.
Sourcepub async fn finish_shutdown(
&self,
graceful_timeout: Duration,
abort_timeout: Duration,
) -> Result<(), TaskShutdownError>
pub async fn finish_shutdown( &self, graceful_timeout: Duration, abort_timeout: Duration, ) -> Result<(), TaskShutdownError>
Drains the closed generation within graceful and forced bounds.
§Errors
Returns an error if admission is open, a task fails unexpectedly, or forced completion reaches its deadline. Timed-out tasks remain tracked and reopening stays disabled.
Sourcepub fn start_generation(&self) -> Result<(), TaskGenerationError>
pub fn start_generation(&self) -> Result<(), TaskGenerationError>
Opens a fresh generation after the prior generation fully drains.
§Errors
Returns an error while the current generation remains open or owns tasks.
Sourcepub fn all_finished(&self) -> bool
pub fn all_finished(&self) -> bool
Returns whether every tracked task has finished.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TaskGroup
impl !UnwindSafe for TaskGroup
impl Freeze for TaskGroup
impl Send for TaskGroup
impl Sync for TaskGroup
impl Unpin for TaskGroup
impl UnsafeUnpin for TaskGroup
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more