Skip to main content

output_all

Function output_all 

Source
pub async fn output_all<R, I>(
    commands: I,
    concurrency: usize,
    runner: &R,
) -> Vec<Result<ProcessResult<String>>> 
where R: ProcessRunner + ?Sized, I: IntoIterator<Item = Command>,
Expand description

Run every command in commands, keeping at most concurrency of them live at once, and collect all their results in input order.

concurrency is clamped to at least 1. Each element is the independent Result of one command: an Err is a spawn/I/O failure; a non-zero exit is an Ok(ProcessResult) whose code you inspect. The batch never short-circuits.

Not cancel-safe: dropping the returned future mid-batch drops the in-flight handles. With an own-group runner (JobRunner) this kills those children; with a shared-group runner (&ProcessGroup) they live until the caller tears the group down. No partial results (F3): the Vec is produced only when the whole batch finishes, so a mid-batch drop also discards the results of commands that had already completed — there is no partial recovery. If you need each result as it lands (to survive a cancellation, or to act on the first finisher without waiting for the slowest), reach for output_stream — the same bounded fan-out as a completion-ordered stream — rather than driving the commands yourself.

This is exactly output_stream collected back into input order; the two share one engine, so their concurrency and no-short-circuit semantics cannot drift.