pub struct Scheduler { /* private fields */ }Implementations§
Source§impl Scheduler
impl Scheduler
Sourcepub fn from_ranges(ranges: &[RangeRecord]) -> Self
pub fn from_ranges(ranges: &[RangeRecord]) -> Self
Build from persisted ranges. Completed ranges stay completed; anything
else becomes pending from its durable prefix — including ranges left in
downloading by a process that died (PRD §12 step 4).
Sourcepub fn acquire(&self) -> Option<(Lease, Option<Split>)>
pub fn acquire(&self) -> Option<(Lease, Option<Split>)>
Claim work: a pending range if one exists, otherwise steal the tail of
the slowest active range. None means “nothing to do right now”.
Sourcepub fn release(&self, idx: u64)
pub fn release(&self, idx: u64)
Release a lease without completing it. The range keeps its durable prefix and goes back in the queue, so one worker’s failure costs only that range (PRD Invariant 6).
Sourcepub fn fail(&self, idx: u64)
pub fn fail(&self, idx: u64)
Give up on a range permanently. The download as a whole fails, but we keep every other range’s progress.
Sourcepub fn set_end(&self, idx: u64, end: u64)
pub fn set_end(&self, idx: u64, end: u64)
When a range’s real length turns out to differ from the plan — an open-ended sequential transfer that just ended — record the true end.
pub fn is_finished(&self) -> bool
pub fn has_failure(&self) -> bool
Sourcepub fn is_drained(&self) -> bool
pub fn is_drained(&self) -> bool
True when no work is available and none will become available — every range is either complete or failed.
pub async fn wait_for_change(&self, timeout: Duration)
pub fn notify(&self)
Sourcepub fn snapshot(&self) -> Vec<RangeRecord>
pub fn snapshot(&self) -> Vec<RangeRecord>
Current view of every range, for the committer and for progress.
pub fn counts(&self) -> (usize, usize)
Sourcepub fn written_bytes(&self) -> u64
pub fn written_bytes(&self) -> u64
Sum of every range’s written prefix — the engine’s view of “downloaded”.