struct State {
core: MockTimeCore,
futures: DenseSlotMap<DefaultKey, Option<Waker>>,
unready: PriorityQueue<DefaultKey, Reverse<Instant>>,
}Expand description
Mutable state for a Provider
Each sleep (Id, SleepFuture) is in one of the following states:
| state | SleepFuture | futures | unready |
|---|---|---|---|
| UNPOLLED | exists | present, None | present, > now |
| WAITING | exists | present, Some | present, > now |
| READY | exists | present, None | absent |
| DROPPED | dropped | absent | absent |
Fields§
§core: MockTimeCoreCurrent time (coarse)
futures: DenseSlotMap<DefaultKey, Option<Waker>>Futures; record of every existing SleepFuture, including any Waker
Entry exists iff SleepFuture exists.
Contains None if we haven’t polled the future;
Some if we have.
We could use a Vec or TiVec
but using a slotmap is more robust against bugs here.
unready: PriorityQueue<DefaultKey, Reverse<Instant>>Priority queue
Subset of futures.
An entry is present iff the Instant is strictly after State.now,
in which case that’s when the future should be woken.
PriorityQueue is a max-heap but we want earliest times, hence Reverse
Implementations§
Trait Implementations§
Source§impl AsMut<DenseSlotMap<DefaultKey, Option<Waker>>> for State
impl AsMut<DenseSlotMap<DefaultKey, Option<Waker>>> for State
Source§fn as_mut(&mut self) -> &mut DenseSlotMap<DefaultKey, Option<Waker>>
fn as_mut(&mut self) -> &mut DenseSlotMap<DefaultKey, Option<Waker>>
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl AsMut<MockTimeCore> for State
impl AsMut<MockTimeCore> for State
Source§fn as_mut(&mut self) -> &mut MockTimeCore
fn as_mut(&mut self) -> &mut MockTimeCore
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl AsMut<PriorityQueue<DefaultKey, Reverse<Instant>>> for State
impl AsMut<PriorityQueue<DefaultKey, Reverse<Instant>>> for State
Source§fn as_mut(&mut self) -> &mut PriorityQueue<DefaultKey, Reverse<Instant>>
fn as_mut(&mut self) -> &mut PriorityQueue<DefaultKey, Reverse<Instant>>
Converts this type into a mutable reference of the (usually inferred) input type.
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnsafeUnpin for State
impl UnwindSafe for State
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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 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> ⓘ
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