pub struct PriorityQueueSet<K: Kernel> {
run_queues: [ForeignList<Thread<K>, ThreadListAdapter<K>>; 32],
ready_bitmask: PriorityBitmask,
}Expand description
A set of intrusive per-priority run queues plus a bitmask of non-empty
priorities, giving constant-time O(1) push, pop, and removal.
A thread’s priority is read from algorithm_state.priority() when it
is queued and must not change while it is linked here.
Fields§
§run_queues: [ForeignList<Thread<K>, ThreadListAdapter<K>>; 32]One run queue per priority level.
Index 0 is the lowest priority, NUM_PRIORITIES - 1 is the highest.
ready_bitmask: PriorityBitmaskBit p is set iff run_queues[p] is non-empty.
Implementations§
Source§impl<K: Kernel> PriorityQueueSet<K>
impl<K: Kernel> PriorityQueueSet<K>
pub const fn new() -> Self
Sourcepub fn push_front(&mut self, thread: ForeignBox<Thread<K>>)
pub fn push_front(&mut self, thread: ForeignBox<Thread<K>>)
Enqueues thread at the head of its priority’s run queue and marks that
priority ready.
Sourcepub fn push_back(&mut self, thread: ForeignBox<Thread<K>>)
pub fn push_back(&mut self, thread: ForeignBox<Thread<K>>)
Enqueues thread at the tail of its priority’s run queue and marks that
priority ready.
Sourcepub fn pop_head(&mut self) -> Option<ForeignBox<Thread<K>>>
pub fn pop_head(&mut self) -> Option<ForeignBox<Thread<K>>>
Dequeues the head of the highest-priority non-empty run queue, clearing that priority’s ready bit if the queue drains.
Returns None if no thread is queued.
Sourcepub unsafe fn remove_element(
&mut self,
element: NonNull<Thread<K>>,
) -> ForeignBox<Thread<K>>
pub unsafe fn remove_element( &mut self, element: NonNull<Thread<K>>, ) -> ForeignBox<Thread<K>>
Removes a specific element from the queue set in strictly O(1) time.
§Safety
Caller must ensure element points to a valid Thread<K> currently
linked in self at element.as_ref().algorithm_state.priority().