pub struct Delay { /* private fields */ }
Expand description
A future representing the notification that an elapsed duration has occurred.
This is created through the Delay::new
or Delay::new_at
methods
indicating when the future should fire at. Note that these futures are not
intended for high resolution timers, but rather they will likely fire some
granularity after the exact instant that they’re otherwise indicated to
fire at.
Implementations§
Source§impl Delay
impl Delay
Sourcepub fn new(dur: Duration) -> Delay ⓘ
pub fn new(dur: Duration) -> Delay ⓘ
Creates a new future which will fire at dur
time into the future.
The returned object will be bound to the default timer for this thread. The default timer will be spun up in a helper thread on first use.
Sourcepub fn new_at(at: Instant) -> Delay ⓘ
pub fn new_at(at: Instant) -> Delay ⓘ
Creates a new future which will fire at the time specified by at
.
The returned object will be bound to the default timer for this thread. The default timer will be spun up in a helper thread on first use.
Sourcepub fn new_handle(at: Instant, handle: TimerHandle) -> Delay ⓘ
pub fn new_handle(at: Instant, handle: TimerHandle) -> Delay ⓘ
Creates a new future which will fire at the time specified by at
.
The returned instance of Delay
will be bound to the timer specified by
the handle
argument.
Sourcepub fn reset(&mut self, dur: Duration)
pub fn reset(&mut self, dur: Duration)
Resets this timeout to an new timeout which will fire at the time
specified by dur
.
This is equivalent to calling reset_at
with Instant::now() + dur
Sourcepub fn reset_at(&mut self, at: Instant)
pub fn reset_at(&mut self, at: Instant)
Resets this timeout to an new timeout which will fire at the time
specified by at
.
This method is usable even of this instance of Delay
has “already
fired”. That is, if this future has resovled, calling this method means
that the future will still re-resolve at the specified instant.
If at
is in the past then this future will immediately be resolved
(when poll
is called).
Note that if any task is currently blocked on this future then that task
will be dropped. It is required to call poll
again after this method
has been called to ensure tha ta task is blocked on this future.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Delay
impl !RefUnwindSafe for Delay
impl Send for Delay
impl Sync for Delay
impl Unpin for Delay
impl !UnwindSafe for Delay
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read moreSource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.Source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.