|
|
@ -60,36 +60,42 @@ pub(crate) trait Context {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(all(not(target_os = "unknown"), feature = "default"))]
|
|
|
|
#[cfg(all(not(target_os = "unknown"), feature = "default"))]
|
|
|
|
pub(crate) type Timer = smol::Timer;
|
|
|
|
mod timer {
|
|
|
|
|
|
|
|
pub type Timer = smol::Timer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(all(target_arch = "wasm32", feature = "default"))]
|
|
|
|
#[cfg(any(
|
|
|
|
#[derive(Debug)]
|
|
|
|
all(target_arch = "wasm32", feature = "default"),
|
|
|
|
pub(crate) struct Timer(futures_timer::Delay);
|
|
|
|
all(feature = "unstable", not(feature = "default"))
|
|
|
|
|
|
|
|
))]
|
|
|
|
|
|
|
|
mod timer {
|
|
|
|
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
|
|
|
use std::task::Poll;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(all(target_arch = "wasm32", feature = "default"))]
|
|
|
|
#[derive(Debug)]
|
|
|
|
impl Timer {
|
|
|
|
pub(crate) struct Timer(futures_timer::Delay);
|
|
|
|
pub(crate) fn after(dur: std::time::Duration) -> Self {
|
|
|
|
|
|
|
|
Timer(futures_timer::Delay::new(dur))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
impl Timer {
|
|
|
|
use std::pin::Pin;
|
|
|
|
pub(crate) fn after(dur: std::time::Duration) -> Self {
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
Timer(futures_timer::Delay::new(dur))
|
|
|
|
use std::task::Poll;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
impl std::future::Future for Timer {
|
|
|
|
impl std::future::Future for Timer {
|
|
|
|
type Output = ();
|
|
|
|
type Output = ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn poll(mut self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> {
|
|
|
|
fn poll(mut self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> {
|
|
|
|
match Pin::new(&mut self.0).poll(cx) {
|
|
|
|
match Pin::new(&mut self.0).poll(cx) {
|
|
|
|
Poll::Pending => Poll::Pending,
|
|
|
|
Poll::Pending => Poll::Pending,
|
|
|
|
Poll::Ready(_) => Poll::Ready(()),
|
|
|
|
Poll::Ready(_) => Poll::Ready(()),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(any(feature = "unstable", feature = "default"))]
|
|
|
|
|
|
|
|
pub(crate) use timer::*;
|
|
|
|
|
|
|
|
|
|
|
|
/// Defers evaluation of a block of code until the end of the scope.
|
|
|
|
/// Defers evaluation of a block of code until the end of the scope.
|
|
|
|
#[cfg(feature = "default")]
|
|
|
|
#[cfg(feature = "default")]
|
|
|
|
#[doc(hidden)]
|
|
|
|
#[doc(hidden)]
|
|
|
|