pub struct TimeContext { /* private fields */ }
Available on crate feature
driver
only.Expand description
A time context for creating Delay
s.
Implementations§
Source§impl TimeContext
impl TimeContext
Sourcepub fn delay(&self, dur: Duration) -> Delay ⓘ
pub fn delay(&self, dur: Duration) -> Delay ⓘ
Returns a future that completes after the specified duration.
Examples found in repository?
examples/time_driver.rs (line 24)
15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let (mut driver, context, shutdown) = fastimer::driver::driver();
std::thread::spawn(move || loop {
if driver.turn() {
break;
}
});
let delay = context.delay(std::time::Duration::from_secs(1));
pollster::block_on(delay); // finish after 1 second
shutdown.shutdown();
}
Sourcepub fn delay_until(&self, when: Instant) -> Delay ⓘ
pub fn delay_until(&self, when: Instant) -> Delay ⓘ
Returns a future that completes at the specified instant.
Trait Implementations§
Source§impl Clone for TimeContext
impl Clone for TimeContext
Source§fn clone(&self) -> TimeContext
fn clone(&self) -> TimeContext
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for TimeContext
impl RefUnwindSafe for TimeContext
impl Send for TimeContext
impl Sync for TimeContext
impl Unpin for TimeContext
impl UnwindSafe for TimeContext
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
Mutably borrows from an owned value. Read more