struct SleepSchedule {
core: MockTimeCore,
sleepers: BinaryHeap<SleepEntry>,
waitfor_waker: Option<Waker>,
sleepers_made: usize,
sleepers_polled: usize,
should_advance: bool,
blocked_advance: HashSet<String>,
allowed_advance: Duration,
}
Expand description
Shared backend for sleep provider and Sleeping futures.
Fields§
§core: MockTimeCore
What time do we pretend it is?
sleepers: BinaryHeap<SleepEntry>
Priority queue of events, in the order that we should wake them.
waitfor_waker: Option<Waker>
If the mock time system is being driven by a WaitFor
, holds a Waker
to wake up that
WaitFor
in order for it to make more progress.
sleepers_made: usize
Number of sleepers instantiated.
sleepers_polled: usize
Number of sleepers polled.
should_advance: bool
Whether an advance is needed.
blocked_advance: HashSet<String>
A set of reasons why advances shouldn’t be allowed right now.
allowed_advance: Duration
A time up to which advances are allowed, irrespective of them being blocked.
Implementations§
Source§impl SleepSchedule
impl SleepSchedule
Sourcefn fire(&mut self)
fn fire(&mut self)
Wake any pending events that are ready according to the current simulated time.
Sourcefn push(&mut self, ent: SleepEntry)
fn push(&mut self, ent: SleepEntry)
Add a new SleepEntry to this schedule.
Sourcefn maybe_advance(&mut self)
fn maybe_advance(&mut self)
If all sleepers made have been polled, set the advance flag and wake up any WaitFor
that
might be waiting.
Sourcefn increment_poll_count(&mut self)
fn increment_poll_count(&mut self)
Register a sleeper as having been polled, and advance if necessary.
Auto Trait Implementations§
impl Freeze for SleepSchedule
impl RefUnwindSafe for SleepSchedule
impl Send for SleepSchedule
impl Sync for SleepSchedule
impl Unpin for SleepSchedule
impl UnwindSafe for SleepSchedule
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
§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> ⓘ
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