pub struct Scheduler {
pub worker_count: usize,
}Expand description
Runs a JobGraph across worker threads, respecting declared
dependencies.
§Implementation note
Every worker pulls from one shared Mutex-guarded ready-queue rather
than each having its own deque with the classic work-stealing protocol
(steal from a random peer when your own queue is empty). A single
shared queue is correct and easy to verify by test; per-worker
lock-free deques are a real throughput win at high job counts, but
implementing that safely is a separate, riskier piece of work — not
worth taking on before there’s a real frame’s worth of jobs to profile
against. Swapping the internals later doesn’t change this type’s API.
Fields§
§worker_count: usizeImplementations§
Source§impl Scheduler
impl Scheduler
pub fn new(worker_count: usize) -> Self
Sourcepub fn run(&self, graph: JobGraph)
pub fn run(&self, graph: JobGraph)
Runs every job in graph to completion. Blocks the calling thread
until the whole graph has finished.
§Panics
Panics if graph contains a dependency cycle, or a JobId that
doesn’t belong to it — both are caller bugs, not runtime
conditions to recover from, and running a cyclic graph would
otherwise hang forever waiting for an in-degree that never reaches
zero.