pub struct DiscardingSpawnGroup {
pub is_cancelled: bool,
/* private fields */
}Expand description
Discarding Spawn Group
A kind of a spawn group that spawns asynchronous tasks that returns nothing,
implicitly waits for all spawned tasks to finish before being dropped
and releases all the resources before being dropped unless by
explicitly calling dont_wait_at_drop()
Child tasks are spawned by calling either spawn_task() or spawn_task_unless_cancelled() methods.
Running child tasks can be cancelled by calling cancel_all() method.
Child tasks spawned to a spawn group execute concurrently, and may be scheduled in any order.
Fields§
§is_cancelled: boolA field that indicates if the spawn group has been cancelled
Implementations§
Source§impl DiscardingSpawnGroup
impl DiscardingSpawnGroup
Sourcepub fn dont_wait_at_drop(&mut self)
pub fn dont_wait_at_drop(&mut self)
Don’t implicity wait for spawned child tasks to finish before being dropped
Source§impl DiscardingSpawnGroup
impl DiscardingSpawnGroup
Sourcepub fn spawn_task(
&mut self,
priority: Priority,
closure: impl Future<Output = ()> + Send + 'static,
)
pub fn spawn_task( &mut self, priority: Priority, closure: impl Future<Output = ()> + Send + 'static, )
Spawns a new task into the spawn group
§Parameters
priority: priority to useclosure: an async closure that doesn’t return anything
Sourcepub fn spawn_task_unlessed_cancelled(
&mut self,
priority: Priority,
closure: impl Future<Output = ()> + Send + 'static,
)
pub fn spawn_task_unlessed_cancelled( &mut self, priority: Priority, closure: impl Future<Output = ()> + Send + 'static, )
Spawn a new task only if the group is not cancelled yet, otherwise does nothing
§Parameters
priority: priority to useclosure: an async closure that return doesn’t return anything
Sourcepub fn cancel_all(&mut self)
pub fn cancel_all(&mut self)
Cancels all running task in the spawn group
Source§impl DiscardingSpawnGroup
impl DiscardingSpawnGroup
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
A Boolean value that indicates whether the group has any remaining tasks.
At the start of the body of a with_spawn_group() call, , or before calling spawn_task or spawn_task_unless_cancelled methods
the spawn group is always empty.
§Returns
- true: if there’s no child task still running
- false: if any child task is still running
Source§impl DiscardingSpawnGroup
impl DiscardingSpawnGroup
Sourcepub async fn wait_for_all(&mut self)
pub async fn wait_for_all(&mut self)
Waits for all remaining child tasks for finish.
Sourcepub fn wait_non_async(&mut self)
pub fn wait_non_async(&mut self)
Waits for all remaining child tasks for finish in non async context.