app_async: use for_each_concurrent
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dmitry Belyaev 2023-08-16 14:48:47 +03:00
parent 6d850be1dc
commit 797f781959
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -57,15 +57,18 @@ async fn zip_reader_task(tx: UnboundedSender<Question>) {
let source_questions = source_questions.stream();
pin_mut!(source_questions);
let converter = source_questions.converter().convert();
pin_mut!(converter);
let mut num: u32 = 0;
while let Some(mut question) = converter.next().await {
question.num = 1 + num;
tx.send(question).expect("send");
num += 1;
}
source_questions
.converter()
.convert()
.enumerate()
.map(|(num, mut question)| {
question.num = 1 + (num as u32);
question
})
.for_each_concurrent(None, |question| async {
tx.send(question).expect("send");
})
.await;
println!("read done");
}