pub struct Group<E> { /* private fields */ }Expand description
A group of concurrent tasks that propagates the first error.
Create a new group with Group::new, spawn tasks with spawn or
try_spawn, and collect results with wait.
Implementations§
Source§impl<E> Group<E>where
E: Send + 'static,
impl<E> Group<E>where
E: Send + 'static,
Sourcepub fn spawn<F, Fut>(&self, f: F)
pub fn spawn<F, Fut>(&self, f: F)
Spawns a new task.
If a concurrency limit was set with set_limit and the maximum
number of tasks is already running, the newly spawned task will block
inside itself (not the caller) until a slot opens up.
This method returns immediately and never blocks the caller.
§Panics
The task must not panic. See the crate-level docs.
Sourcepub fn try_spawn<F, Fut>(&self, f: F) -> bool
pub fn try_spawn<F, Fut>(&self, f: F) -> bool
Tries to spawn a new task without waiting for a concurrency slot.
If a limit is set and the maximum number of tasks is running, returns
false without spawning the task. Otherwise spawns the task and
returns true.
If no limit was set, this is equivalent to spawn
and always returns true.