pub struct PollingClock { /* private fields */ }Expand description
A fixed clock whose waits end only as its time reaches them. A backoff or
cooldown the code waits out passes as the code arms it: this clock moves
the fixed clock to the wait’s end, as the wait’s passing would, so retries
run without real time and their timestamps are the waits the code chose.
A deadline, which work races, and the idle interval end only when the test
moves the clock, as does every wait once hold_waits is set. It records
each wait_out it is given.
Implementations§
Source§impl PollingClock
impl PollingClock
Sourcepub fn new(clock: Arc<FixedClock>) -> PollingClock
pub fn new(clock: Arc<FixedClock>) -> PollingClock
A polling clock over clock, which it moves.
Sourcepub fn hold_waits(&self)
pub fn hold_waits(&self)
End later waits by the test’s moves of the fixed clock alone; a wait armed before ends as its own move reaches it.
Sourcepub fn release_waits(&self)
pub fn release_waits(&self)
Pass later waits as the code arms them again; a wait armed while they were held still ends only when the fixed clock reaches it.
Sourcepub fn holds_waits(&self) -> bool
pub fn holds_waits(&self) -> bool
Whether waits are held.
Trait Implementations§
Source§impl Clock for PollingClock
impl Clock for PollingClock
Source§fn now(&self) -> SystemTime
fn now(&self) -> SystemTime
Source§fn elapsed(&self) -> Duration
fn elapsed(&self) -> Duration
Source§fn deadline(
&self,
duration: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send>>
fn deadline( &self, duration: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send>>
duration of elapsed time has passed: a deadline that
work races, such as a sign-in’s wait for its callback or a stalled
transfer’s, or an interval, such as the idle time between passes.
System clocks use the runtime’s monotonic timer; controlled clocks
wake only when their supplied time advances.Source§fn wait_out(&self, wait: Duration) -> Pin<Box<dyn Future<Output = ()> + Send>>
fn wait_out(&self, wait: Duration) -> Pin<Box<dyn Future<Output = ()> + Send>>
wait before trying again: a backoff, a provider’s
cooldown, or the spacing between requests the code chose. It passes
as a deadline of the same length does; a test’s clock may move its
time to the wait’s end as the code arms it, since no work races it.Source§fn sleep_until(
&self,
at: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<(), WallTimerError>> + Send>>
fn sleep_until( &self, at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<(), WallTimerError>> + Send>>
at or later, however it gets
there: by running, or by being set past it (§13.2). A time already
reached ends the wait at once, and a clock set back moves the wait’s
end with it. The clock itself says when it reaches at; nothing reads
it again on a timer. A clock that can’t say fails the wait.Auto Trait Implementations§
impl !Freeze for PollingClock
impl RefUnwindSafe for PollingClock
impl Send for PollingClock
impl Sync for PollingClock
impl Unpin for PollingClock
impl UnsafeUnpin for PollingClock
impl UnwindSafe for PollingClock
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>
§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