native_executor/polyfill/
timer.rs1#![allow(dead_code)]
2
3use std::future::Future;
4
5#[derive(Debug)]
6pub struct PolyfillTimer {
7 timer: async_io::Timer,
8}
9
10impl PolyfillTimer {
11 #[must_use]
12 pub fn after(duration: std::time::Duration) -> Self {
13 Self {
14 timer: async_io::Timer::after(duration),
15 }
16 }
17}
18
19impl Future for PolyfillTimer {
20 type Output = ();
21 fn poll(
22 mut self: std::pin::Pin<&mut Self>,
23 cx: &mut std::task::Context<'_>,
24 ) -> std::task::Poll<Self::Output> {
25 std::pin::Pin::new(&mut self.timer).poll(cx).map(|_| ())
26 }
27}