Skip to main content

BoundedQueue

Struct BoundedQueue 

Source
pub struct BoundedQueue {
    pub backpressure_active: bool,
    /* private fields */
}
Expand description

A single bounded queue of IndexJobs, ordered by priority then insertion order (RFC-036 §8).

Fields§

§backpressure_active: bool

Whether backpressure is currently active for this queue.

Implementations§

Source§

impl BoundedQueue

Source

pub fn new(kind: QueueKind, capacity: usize) -> Self

Source

pub fn kind(&self) -> QueueKind

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_full(&self) -> bool

true when the queue has reached its capacity ceiling. Callers must not push when this returns true.

Source

pub fn remaining(&self) -> usize

Remaining capacity.

Source

pub fn capacity(&self) -> usize

Source

pub fn total_pushed(&self) -> u64

Source

pub fn push(&mut self, job: IndexJob)

Push a job into the queue, maintaining priority order.

§Ordering invariant

pop_back serves the item at the highest index. To dispatch the highest-priority job first, and within equal priority the oldest job first (FIFO), items must be stored with:

  • higher-priority items at higher indices (closer to back), and
  • among equal-priority items, older items at higher indices.
§Insertion rule

The new job is inserted at the first index (from the back) where the existing item has strictly lower priority than the new job. This places it after (higher index than) all equal-or-higher priority items already in the queue, satisfying both conditions.

Panics if the queue is full — callers must check is_full first.

Source

pub fn pop(&mut self) -> Option<IndexJob>

Pop the highest-priority job (front of the queue).

Source

pub fn peek(&self) -> Option<&IndexJob>

Peek at the highest-priority job without removing it.

Source

pub fn cancel_for_source(&mut self, source_id: &SourceId) -> usize

Cancel all jobs belonging to source_id (RFC-036 §12.3). Returns the number of jobs removed.

Source

pub fn clear(&mut self) -> usize

Drain all jobs (e.g. on full scheduler reset).

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more