Skip to main content

Scheduler

Struct Scheduler 

Source
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: usize

Implementations§

Source§

impl Scheduler

Source

pub fn new(worker_count: usize) -> Self

Source

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.

Trait Implementations§

Source§

impl Debug for Scheduler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.