pub async fn with_discarding_spawn_group<Closure, Fut, ReturnType>(
body: Closure,
) -> ReturnTypeExpand description
Starts a scoped closure that takes a mutable DiscardingSpawnGroup instance as an argument which can execute any number of child tasks which return nothing.
Ensures that before the function call ends, all spawned tasks are implicitly waited for
This function use a threadpool of the same number of threads as the number of active processor count that is default amount of parallelism a program can use on the system for polling the spawned tasks
See DiscardingSpawnGroup
for more.
§Parameters
body: an async closure that takes an instance ofDiscardingSpawnGroupas an argument
§Returns
Anything the body parameter returns
§Example
use spawn_groups::GetType;
use spawn_groups::with_discarding_spawn_group;
use futures_lite::StreamExt;
use spawn_groups::Priority;
with_discarding_spawn_group(|mut group| async move {
for i in 0..11 {
group.spawn_task(Priority::default(), async move {
// asynchronous processing
// or some async network calls
});
}
}).await;