Struct heph::timer::Timer [−][src]
pub struct Timer<RT: Access> { /* fields omitted */ }
Expand description
A Future
that represents a timer.
If this future returns Poll::Ready
(
DeadlinePassed
)
it means that
the deadline has passed. If it returns Poll::Pending
it’s not yet
passed.
Examples
use std::time::Duration; use heph::actor; use heph::rt::ThreadLocal; use heph::timer::Timer; async fn actor(mut ctx: actor::Context<!, ThreadLocal>) { // Create a timer, this will be ready once the timeout has passed. let timeout = Timer::after(&mut ctx, Duration::from_millis(200)); // Wait for the timer to pass. timeout.await; println!("200 milliseconds have passed!"); }
Implementations
Create a new Timer
.
Create a new timer, based on a timeout.
Same as calling Timer::at(&mut ctx, Instant::now() + timeout)
.
Returns true
if the deadline has passed.
Trait Implementations
Auto Trait Implementations
impl<RT> RefUnwindSafe for Timer<RT> where
RT: RefUnwindSafe,
impl<RT> UnwindSafe for Timer<RT> where
RT: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (
into_future
)The output that the future will produce on completion.
type Future = F
type Future = F
🔬 This is a nightly-only experimental API. (
into_future
)Which kind of future are we turning this into?
🔬 This is a nightly-only experimental API. (
into_future
)Creates a future from a value.