use std::task::{Context, Poll};
use tokio::time::Instant;
#[allow(dead_code)]
mod fallback;
#[cfg(all(feature = "os-native", any(target_os = "linux", target_os = "android")))]
mod linux;
#[cfg(all(feature = "os-native", any(target_os = "linux", target_os = "android")))]
use linux as imp;
#[cfg(all(
feature = "os-native",
any(
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly",
),
))]
mod bsd;
#[cfg(all(
feature = "os-native",
any(
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly",
),
))]
use bsd as imp;
#[cfg(all(feature = "os-native", windows))]
mod windows;
#[cfg(all(feature = "os-native", windows))]
use windows as imp;
#[cfg(any(
not(feature = "os-native"),
not(any(
target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly",
windows,
)),
))]
use fallback as imp;
pub(crate) struct Timer(imp::Timer);
impl Timer {
pub(crate) fn new() -> Self {
Timer(imp::Timer::new())
}
pub(crate) fn arm(&mut self, deadline: Instant) {
self.0.arm(deadline);
}
pub(crate) fn disarm(&mut self) {
self.0.disarm();
}
pub(crate) fn poll_expired(&mut self, cx: &mut Context<'_>) -> Poll<()> {
self.0.poll_expired(cx)
}
}
impl std::fmt::Debug for Timer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Timer").finish_non_exhaustive()
}
}