Skip to content

Commit

Permalink
fix: run more kupo queries in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
SupernaviX committed Mar 3, 2025
1 parent 63132b7 commit 7373e88
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/sources/kupo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,17 @@ impl<F: Future> MaxConcurrencyFutureSet<F> {
}

pub fn push(&mut self, future: F) {
if self.running.len() < self.concurrency {
self.running.push(future);
} else {
self.queued.push(future);
}
self.queued.push(future);
}

pub async fn next(&mut self) -> Option<F::Output> {
let next = self.running.next().await;
if next.is_none() {
while self.running.len() < self.concurrency {
if let Some(another_task) = self.queued.pop() {
self.running.push(another_task);
return self.running.next().await;
} else {
break;
}
}
next
self.running.next().await
}
}

0 comments on commit 7373e88

Please sign in to comment.