Skip to main content

Scheduler

Struct Scheduler 

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

Scheduler state.

Implementations§

Source§

impl Scheduler

Source

pub fn new(policy: SchedPolicy) -> Self

Create a scheduler with the given policy.

Source

pub fn add_ready(&mut self, coro_id: usize)

Register a coroutine as ready.

Source

pub fn mark_blocked(&mut self, coro_id: usize, reason: BlockReason)

Mark a coroutine as blocked.

Source

pub fn mark_done(&mut self, coro_id: usize)

Mark a coroutine as done (remove from all queues).

Source

pub fn unblock(&mut self, coro_id: usize)

Unblock a coroutine (move from blocked to ready).

§

impl Scheduler

pub fn schedule(&mut self) -> Option<usize>

Pick the next coroutine to execute, or None if none are ready.

pub fn schedule_with<F>(&mut self, has_progress: F) -> Option<usize>
where F: Fn(usize) -> bool,

Pick the next coroutine using a progress predicate.

pub fn pick_runnable<F>(&mut self, has_progress: F) -> Option<usize>
where F: Fn(usize) -> bool,

Lean-aligned scheduler pick entrypoint.

pub fn pick_eligible_runnable<F>(&mut self, has_progress: F) -> Option<usize>
where F: Fn(usize) -> bool + Copy,

Pick the next runnable coroutine restricted to cached ready eligibility.

pub fn update_after_step(&mut self, coro_id: usize, update: StepUpdate)

Lean-aligned scheduler state transition helper.

pub fn reschedule(&mut self, coro_id: usize)

Re-enqueue a coroutine that yielded or completed an instruction.

pub fn is_ready(&self, coro_id: usize) -> bool

Return whether a coroutine is currently in the global ready set.

pub fn ready_count(&self) -> usize

Number of ready coroutines.

pub fn ready_snapshot(&self) -> Vec<usize>

Snapshot of the current global ready queue order.

pub fn ready_set_snapshot(&self) -> BTreeSet<usize>

Snapshot of current ready coroutine IDs as a set.

pub fn any_ready<F>(&self, predicate: F) -> bool
where F: FnMut(usize) -> bool,

Return whether any ready coroutine satisfies predicate.

pub fn blocked_count(&self) -> usize

Number of blocked coroutines.

pub fn is_stuck(&self) -> bool

Whether all coroutines are either done or blocked (no progress possible).

pub fn step_count(&self) -> usize

Total steps executed.

pub fn policy(&self) -> &SchedPolicy

Current policy.

pub fn timeslice(&self) -> usize

Configured timeslice.

pub fn block_reason(&self, coro_id: usize) -> Option<&BlockReason>

Get the block reason for a coroutine, if blocked.

pub fn blocked_ids(&self) -> Vec<usize>

All blocked coroutine IDs.

pub fn blocked_snapshot(&self) -> BTreeMap<usize, BlockReason>

Snapshot of blocked coroutine reasons.

pub fn has_eligible_ready(&self) -> bool

Whether any coroutine is currently cached as both ready and eligible.

pub fn set_ready_eligibility( &mut self, coro_id: usize, eligibility: ReadyEligibility, )

Update cached ready eligibility for a coroutine.

pub fn clear_ready_eligibility(&mut self)

Clear all cached ready eligibility state.

pub fn assign_lane(&mut self, coro_id: usize, lane: LaneId)

Assign a coroutine to a specific lane.

pub fn lane_of(&self, coro_id: usize) -> Option<LaneId>

Lane assignment for a coroutine.

pub fn lane_queues_snapshot(&self) -> BTreeMap<LaneId, Vec<usize>>

Snapshot of per-lane ready queues.

pub fn lane_blocked_snapshot( &self, ) -> BTreeMap<LaneId, BTreeMap<usize, BlockReason>>

Snapshot of per-lane blocked coroutines.

pub fn record_cross_lane_handoff( &mut self, from_coro: usize, to_coro: usize, reason: impl Into<String>, )

Record a cross-lane handoff.

pub fn cross_lane_handoffs(&self) -> &[CrossLaneHandoff]

Cross-lane handoff log.

Trait Implementations§

Source§

impl Debug for Scheduler

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Scheduler

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Scheduler

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,