rmanoka / async-scoped

A scope for async_std and tokio to spawn non-static futures
117 stars 14 forks source link

Limiting concurrent tasks #30

Closed LDeakin closed 6 months ago

LDeakin commented 6 months ago

Is it possible with this crate to limit the number of concurrent spawned tasks in a scope?

For reference, I currently do this with unscoped tasks:

let mut stream = futures::stream::iter(futures).map(tokio::task::spawn).buffer_unordered(concurrent_limit);
while let Some(result) = stream.next().await {
   // ... handle result
}
LDeakin commented 6 months ago

Never mind, I realised I can do it using a spawner directly. Thanks for this great crate!