pub struct TaskGroup { /* private fields */ }Expand description
Implementations§
Source§impl TaskGroup
impl TaskGroup
Sourcepub fn serial(pool: &Pool) -> TaskGroup
pub fn serial(pool: &Pool) -> TaskGroup
A new lane of pool that runs at most one of its tasks at a time, in
the order they were spawned, on whichever thread takes each. A task
that one of its tasks spawns into the group runs after that task.
Sourcepub fn spawn(&self, task: impl FnOnce() + Send + 'static)
pub fn spawn(&self, task: impl FnOnce() + Send + 'static)
Runs task on the pool, in the group’s lane.
Sourcepub fn wait(&self)
pub fn wait(&self)
Returns once none of the group’s tasks are queued or running,
including those they spawn into the group meanwhile. It runs the
queued ones on this thread, where a task that panics counts as ended
as it does on a worker, then waits for those that run on the pool’s
workers. A serial group’s next task runs here only
once none of its tasks runs elsewhere. On a local
pool it doesn’t wait: a task that runs there runs on this thread,
below this call, so a serial group’s tasks queued behind it stay
queued.
§Panics
On one of the pool’s workers, which a running task could be waiting for.