pub struct TaskGroup<S: Spawn, C: Deref<Target = State>> { /* private fields */ }
Expand description
A group of potentially related tasks. Tasks spawned by this struct can be waited on or signaled to shut down.
Implementations§
Source§impl<S: Spawn> TaskGroup<S, &'static State>
impl<S: Spawn> TaskGroup<S, &'static State>
Sourcepub fn with_static(spawner: S, state: &'static State) -> Self
pub fn with_static(spawner: S, state: &'static State) -> Self
Create a new task group using the provided spawner and state
Source§impl<S: Spawn, C: 'static + Deref<Target = State> + Clone + Send> TaskGroup<S, C>
impl<S: Spawn, C: 'static + Deref<Target = State> + Clone + Send> TaskGroup<S, C>
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Signal a shutdown to all tasks in this group and wait for shutdown to finish.
Sourcepub async fn done(&self)
pub async fn done(&self)
Wait for all tasks in this group to finish without explicitly sending a shutdown signal.
Sourcepub fn spawn(&self, future: impl Future<Output = ()> + Send + 'static)
pub fn spawn(&self, future: impl Future<Output = ()> + Send + 'static)
Spawn a task as part of this task group
pub fn spawn_with_shutdown<F>(&self, f: impl FnOnce(ShutdownSignal<C>) -> F)
Auto Trait Implementations§
impl<S, C> Freeze for TaskGroup<S, C>
impl<S, C> RefUnwindSafe for TaskGroup<S, C>where
S: RefUnwindSafe,
C: RefUnwindSafe,
impl<S, C> Send for TaskGroup<S, C>
impl<S, C> Sync for TaskGroup<S, C>
impl<S, C> Unpin for TaskGroup<S, C>
impl<S, C> UnwindSafe for TaskGroup<S, C>where
S: UnwindSafe,
C: UnwindSafe,
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