Skip to main content

SystemScheduler

Struct SystemScheduler 

Source
pub struct SystemScheduler { /* private fields */ }
Expand description

DAG scheduler that runs systems in topological order with boolean propagation.

Created by SchedulerInstaller via WorldBuilder::install_driver. This is a user-space driver — the caller decides when and whether to call run.

§Propagation

Root systems (no upstream) always run. Non-root systems run only if at least one upstream returned true.

§Bitmask implementation

Each system occupies one bit position in a u64. During run, a local results: u64 accumulates which systems returned true. Each system’s upstream check is:

mask == 0              → root, always run
(mask & results) != 0  → at least one upstream returned true

One load, one AND, one branch per system — no heap access for the propagation check itself. The results bitmask lives in a register for the duration of the loop.

Implementations§

Source§

impl SystemScheduler

Source

pub fn run(&mut self, world: &mut World) -> usize

Run all systems with boolean propagation.

Iterates systems in topological order. For each system:

  1. Root (upstream_mask == 0): always runs.
  2. Non-root (upstream_mask & results != 0): runs if any upstream returned true. Skipped otherwise.
  3. If the system runs and returns true, its bit is set in results, enabling downstream systems to run.

The results bitmask is a local u64 — the entire propagation state fits in a single register. Per-system overhead is one load + one AND + one branch (~4 cycles).

Does NOT call next_sequence — the global sequence is event-only.

Returns the number of systems that actually ran.

Source

pub fn len(&self) -> usize

Returns the number of systems in the scheduler.

Source

pub fn is_empty(&self) -> bool

Returns true if the scheduler contains no systems.

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.