pub struct Deadline { /* private fields */ }Expand description
Implementations§
Source§impl Deadline
impl Deadline
Sourcepub fn new(duration: Millis) -> Deadline ⓘ
pub fn new(duration: Millis) -> Deadline ⓘ
Creates a new deadline future.
A zero duration creates a deadline that never completes.
Sourcepub async fn wait(&self)
pub async fn wait(&self)
Waits until this deadline has elapsed.
Only one task may wait at a time; see single waiter.
Sourcepub fn reset<T>(&mut self, millis: T)
pub fn reset<T>(&mut self, millis: T)
Resets the Deadline instance to a new deadline.
Calling this function allows changing the instant at which the Deadline
future completes without having to create new associated state.
This function can be called both before and after the future has completed.
Sourcepub fn is_elapsed(&self) -> bool
pub fn is_elapsed(&self) -> bool
Returns true if Deadline has elapsed.
This agrees with polling: it returns true exactly when polling the
deadline completes. A disabled zero-duration deadline never elapses,
so it returns false.
Sourcepub fn poll_elapsed(&self, cx: &mut Context<'_>) -> Poll<()>
pub fn poll_elapsed(&self, cx: &mut Context<'_>) -> Poll<()>
Polls until this deadline has elapsed.
A zero-duration deadline remains pending until it is reset. A pending poll replaces the previously registered waker; see single waiter.