pub async fn run_concurrent_streams(
estimated_total: u64,
stream_count: usize,
progress: Arc<Tracker>,
label: &str,
spawn_fn: impl FnMut(usize, Arc<LoopState>, u64) -> JoinHandle<Result<(), Error>>,
) -> Result<BandwidthResult, Error>Expand description
Run a bandwidth test using multiple concurrent streams.
This is the shared spawn/collect/report pattern used by both download and upload tests. It:
- Creates a
LoopStatefor the test - Spawns
stream_counttasks viaspawn_fn - Collects results, logging any task panics
- Returns a
BandwidthResult(zeroed if all tasks failed)
The spawn_fn closure receives the stream index and a shared reference
to the loop state. Each call should create and return a JoinHandle<()>
that performs I/O and calls LoopState::record_bytes for each
transferred chunk.
§Arguments
estimated_total— Estimated total bytes for progress bar initializationstream_count— Number of concurrent streams to spawnprogress— Shared progress bar for the test phasespawn_fn— Closure that creates one stream’s async task
§Panics
Individual task panics are caught and logged; they do not propagate.