Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. kernel
  6. PriorityQueueSet

PriorityQueueSet

Struct PriorityQueueSet 

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

Bit p is set iff run_queues[p] is non-empty.

Implementations§

Source§

impl<K: Kernel> PriorityQueueSet<K>

Source

pub const fn new() -> Self

Source

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.

Source

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.

Source

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.

Source

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().

Auto Trait Implementations§

§

impl<K> !RefUnwindSafe for PriorityQueueSet<K>

§

impl<K> !Unpin for PriorityQueueSet<K>

§

impl<K> !UnwindSafe for PriorityQueueSet<K>

§

impl<K> Forget for PriorityQueueSet<K>

§

impl<K> Freeze for PriorityQueueSet<K>
where [ForeignList<Thread<K>, ThreadListAdapter<K>>; 32]: Freeze,

§

impl<K> Move for PriorityQueueSet<K>

§

impl<K> Send for PriorityQueueSet<K>
where [ForeignList<Thread<K>, ThreadListAdapter<K>>; 32]: Send,

§

impl<K> Sync for PriorityQueueSet<K>
where [ForeignList<Thread<K>, ThreadListAdapter<K>>; 32]: Sync,

§

impl<K> UnsafeUnpin for PriorityQueueSet<K>
where [ForeignList<Thread<K>, ThreadListAdapter<K>>; 32]: UnsafeUnpin,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

fn cast_into(self) -> U

§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.