Struct WaitQueue
pub struct WaitQueue { /* private fields */ }std only.Expand description
Parties waiting, in arrival order, for capacity that others free.
A Party queues a Waiter with Self::push before it checks the
capacity it waits for; whoever frees capacity calls Self::wake_one for one
unit, or Self::wake_all for a change of unknown size, after freeing it.
Both sides fence, so of a waiter queuing and capacity freeing at once, one
sees the other. Every unit reaches a waiter, which spends it on a look or, as
it leaves, passes it on in this queue. Nothing else is locked while its lock
is held, but the wakers of the parties it wakes run under it, so a wake and
a leave never interleave: a waker must not call back into the queue, and an
async runtime’s does not.
Capacity several queues contend for goes to the oldest of their fronts: a party leaving it to an older waiter of another queue gives way to it.
Implementations§
§impl WaitQueue
impl WaitQueue
pub fn push(&self, waiter: &Waiter)
Available on crate features grpc and http only.
pub fn push(&self, waiter: &Waiter)
grpc and http only.Queue waiter behind the older parties. Check the capacity it waits for
after.
pub fn remove(&self, waiter: &Waiter) -> usize
Available on crate features grpc and http only.
pub fn remove(&self, waiter: &Waiter) -> usize
grpc and http only.Leave the queue, returning the wakes it sent the waiter that are not spent: capacity they stand for and the waiter does not use is left to the others, so pass it on. Queues whose parties gave way to the waiter get a wake.
A party freeing capacity meets the leave under the queue’s lock: it wakes the waiter before, or reports nobody waiting after.
pub fn give_way(&self, than: u64, giver: &Waiter) -> bool
Available on crate features grpc and http only.
pub fn give_way(&self, than: u64, giver: &Waiter) -> bool
grpc and http only.Whether a waiter older than than waits here, for capacity the party of
giver, its place in another queue, contends for too: that party gives
way to it. The waiter is woken to look, if it holds no wake, and giver
once it leaves, if its party still waits: atomic with the leave, so that
wake is not lost.
pub fn front_order(&self) -> Option<u64>
Available on crate features grpc and http only.
pub fn front_order(&self) -> Option<u64>
grpc and http only.The Party::order of the first waiter, if any waits.
pub fn front_is_woken(&self) -> bool
Available on crate features grpc and http only.
pub fn front_is_woken(&self) -> bool
grpc and http only.Whether the first waiter holds a wake: capacity is being handed down the queue.
pub fn unspent(&self) -> usize
Available on crate features grpc and http only.
pub fn unspent(&self) -> usize
grpc and http only.The wakes this queue sent its waiters that they did not spend,
saturating at usize::MAX.
pub fn admits(&self, waiter: Option<&Waiter>) -> bool
Available on crate features grpc and http only.
pub fn admits(&self, waiter: Option<&Waiter>) -> bool
grpc and http only.Whether a party may take capacity now: nobody waits ahead of it, or it
holds a wake of this queue. None is a party that does not wait here.
pub fn wake_front(&self) -> bool
Available on crate features grpc and http only.
pub fn wake_front(&self) -> bool
grpc and http only.Make the first waiter look after this: a wake if it holds none, else a look more without a unit of capacity, so a look of it that began before runs once more. False if nobody waits.
pub fn wake_one(&self) -> bool
Available on crate features grpc and http only.
pub fn wake_one(&self) -> bool
grpc and http only.One unit of capacity: wake the first waiter without a wake of this queue or, if all of them hold one, the first again, since its look may have begun before the unit. False if nobody waits: the capacity is nobody’s.
pub fn wake_many(&self, n: usize) -> bool
Available on crate features grpc and http only.
pub fn wake_many(&self, n: usize) -> bool
grpc and http only.n units of capacity at once: as Self::wake_one n times, in one
pass over the queue. False if nobody waits.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WaitQueue
impl !RefUnwindSafe for WaitQueue
impl !UnwindSafe for WaitQueue
impl Send for WaitQueue
impl Sync for WaitQueue
impl Unpin for WaitQueue
impl UnsafeUnpin for WaitQueue
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more