pub struct FairClassRq { /* private fields */ }Expand description
Per-CPU run queue for the Completely Fair Scheduler.
Uses two BTreeMaps for O(log n) operations without allocation on the
fast paths (pick_next, remove):
entities: primary map keyed by(vruntime, task_id): the minimum entry is always the next task to schedule.by_id: reverse index mappingtask_id → primary key: enables O(log n) removal by task ID inremove()without scanningentities.
This replaces the previous BinaryHeap-based design which used lazy
deletion (O(n) remove() scan, phantom entries, generation counters).
The BTreeMap approach gives:
| Operation | Complexity | Allocates? |
|---|---|---|
enqueue | O(log n) | yes : 2 BTreeMap nodes (wakeup path) |
pick_next | O(log n) | no : removes 2 nodes |
remove | O(log n) | no : removes 2 nodes |
No phantom entries means no generation counter, no prune_stale_head(),
and no per-entry liveness checks. The BTreeMap pair is the authoritative
record of which tasks are currently on the run queue.
Implementations§
Source§impl FairClassRq
impl FairClassRq
Trait Implementations§
Source§impl SchedClassRq for FairClassRq
impl SchedClassRq for FairClassRq
Source§fn enqueue(&mut self, task: Arc<Task>)
fn enqueue(&mut self, task: Arc<Task>)
Enqueues a task onto the run queue.
Clamps vruntime to min_vruntime so waking tasks do not receive an
unfair head start over tasks that have been waiting. O(log n);
allocates two BTreeMap nodes.
Source§fn pick_next(&mut self) -> Option<Arc<Task>>
fn pick_next(&mut self) -> Option<Arc<Task>>
Picks the next task to run: the one with the smallest vruntime.
O(log n), allocation-free.
Source§fn update_current(
&mut self,
rt: &CurrentRuntime,
task: &Task,
is_yield: bool,
) -> bool
fn update_current( &mut self, rt: &CurrentRuntime, task: &Task, is_yield: bool, ) -> bool
Updates the vruntime of the currently-running task and decides whether it should be preempted.
Returns true if the task has exhausted its time slice or its vruntime
has overtaken the leftmost task’s vruntime by more than vtime_slice.
Auto Trait Implementations§
impl Freeze for FairClassRq
impl !RefUnwindSafe for FairClassRq
impl Send for FairClassRq
impl Sync for FairClassRq
impl Unpin for FairClassRq
impl UnsafeUnpin for FairClassRq
impl !UnwindSafe for FairClassRq
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more