fix(queue): dispatch admitted downloads concurrently

This commit is contained in:
NimBold
2026-07-25 16:50:00 +03:30
parent d62e0429a4
commit dd7c2196fe
2 changed files with 100 additions and 1 deletions
+9 -1
View File
@@ -1199,7 +1199,15 @@ impl<R: tauri::Runtime> QueueManager<R> {
loop {
let notified = self.notify.notified();
if let Some((permit, task)) = self.try_admit_next_task().await {
Arc::clone(&self).dispatch_one(permit, task).await;
// Admission owns the global and per-queue reservation before
// this task is spawned. Keep the dispatcher free to admit
// other work while an Aria2 addUri call is retrying or a
// control RPC is slow; dispatch_one retains the reservation
// until that lifecycle reaches its own terminal path.
let manager = Arc::clone(&self);
tauri::async_runtime::spawn(async move {
manager.dispatch_one(permit, task).await;
});
} else {
// This covers both an empty pending list and the case where
// all queue/global capacity is occupied. The notification