mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-12-06 15:54:41 +01:00
The queue loop only woke when a book finished, so books queued a moment after it started sat idle until an in-flight download happened to complete. Observed as one book downloading alone for 15 seconds with a limit of 5, then four starting within 37ms of the first finishing. The loop now waits on whichever comes first: an active task completing, or a new book being queued. The enqueue signal is captured before the queue is inspected, so a book queued between TryDequeueNext and the wait completes the token already held rather than a fresh one - otherwise the wakeup is lost and the loop sleeps until something else finishes. The 'nothing left, exit' path re-checks the same signal for the same reason.