Skip to main content

WaitQueue

Struct WaitQueue 

pub struct WaitQueue<I: Copy + Eq + Hash> { /* private fields */ }
Expand description

Waiters for one limit’s permits: highest level first, then the levels’ fairness keys in turn (weighted round-robin), then arrival order within a key. Deterministic, so a replicated server can apply it as a state machine. A queue of default-priority waiters only saves as the plain arrival-order list queues always saved as; any other as its levels.

Implementations§

§

impl<I: Copy + Eq + Hash> WaitQueue<I>

pub fn len(&self) -> usize

pub fn is_empty(&self) -> bool

pub fn contains(&self, id: &I) -> bool

pub fn push(&mut self, id: I, p: &Priority) -> bool

Queues id behind the waiters of its key and level. A waiter that is already queued keeps its place and priority; returns whether it was added.

pub fn next(&self) -> Option<I>

The waiter served next.

pub fn pop_next(&mut self) -> Option<I>

Removes the waiter served next and moves the turn on: its key keeps the turn until it has taken its weight’s worth of permits.

pub fn remove(&mut self, id: &I) -> bool

Withdraws a waiter; returns whether it was queued.

pub fn retain(&mut self, keep: impl FnMut(&I) -> bool)

Withdraws every waiter keep refuses.

pub fn reindex(&mut self) -> Result<(), String>

Rebuilds the index from the levels (after deserializing); fails on a waiter queued twice or a malformed level.

Trait Implementations§

§

impl<I: Clone + Copy + Eq + Hash> Clone for WaitQueue<I>

§

fn clone(&self) -> WaitQueue<I>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<I: Debug + Copy + Eq + Hash> Debug for WaitQueue<I>

§

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

Formats the value using the given formatter. Read more
§

impl<I: Copy + Eq + Hash> Default for WaitQueue<I>

§

fn default() -> Self

Returns the “default value” for a type. Read more
§

impl<'de, I> Deserialize<'de> for WaitQueue<I>
where I: Copy + Eq + Hash + Deserialize<'de>,

§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

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

impl<I: Copy + Eq + Hash> PartialEq for WaitQueue<I>

§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<I: Copy + Eq + Hash + Serialize> Serialize for WaitQueue<I>

§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<I> Freeze for WaitQueue<I>

§

impl<I> RefUnwindSafe for WaitQueue<I>
where I: RefUnwindSafe,

§

impl<I> Send for WaitQueue<I>
where I: Send,

§

impl<I> Sync for WaitQueue<I>
where I: Sync,

§

impl<I> Unpin for WaitQueue<I>
where I: Unpin,

§

impl<I> UnsafeUnpin for WaitQueue<I>

§

impl<I> UnwindSafe for WaitQueue<I>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,