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 |
---|---|---|---|
UNPOLLLED | exists | present, None | present, > now |
WAITING | exists | present, Some | present, > now |
READY | exists | present, None | absent |
DROPPED | dropped | absent | absent |
Fields§
§core: MockTimeCore
Current 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<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.
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations§
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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