Expand description
DownloadQueue — a bounded, first-come-first-serve queue over a Downloader (#1435 req. 1):
capsule downloads are QUEUED and scheduled a few at a time, not all fired at once.
§Why queue at all
The #1423 cache-fill flywheel can enqueue many capsule downloads at once. Launching them all
concurrently would saturate this node’s own bandwidth and open unbounded peer connections. The
queue caps the number of active downloads (max_active, default 3); the rest wait in arrival
order and start as slots free up.
§The FCFS guarantee
Submissions run through one FIFO channel drained by exactly max_active worker tasks. A job is
received only when a worker is idle, and the channel yields jobs in submission order — so at most
max_active downloads run at once and they START in the order they were submitted (no reordering,
no starvation).
Each submit returns a QueuedHandle carrying the same live progress
event stream and terminal result as a direct Downloader::download, so a caller cannot tell
whether its download ran immediately or waited for a slot.
Structs§
- Download
Queue - A bounded FCFS scheduler in front of a
Downloader:submitas many downloads as you like; at mostmax_activerun concurrently and the rest wait their turn in arrival order. - Queued
Handle - A handle to a queued download: the live progress
DownloadEventstream plus the terminal result viajoin— the same surface as a direct download, whether it ran now or waited.
Constants§
- DEFAULT_
MAX_ ACTIVE_ DOWNLOADS - The default number of capsule downloads allowed to run at once (the rest queue).