From 4ccc7d3dcb84f7f8e6556a4cd52efc18df1dc887 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 27 Sep 2022 20:47:13 +0200 Subject: [PATCH] Add `delay_until` a specific time --- macros/src/codegen/monotonic.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/macros/src/codegen/monotonic.rs b/macros/src/codegen/monotonic.rs index ad69af9452..1aa11820da 100644 --- a/macros/src/codegen/monotonic.rs +++ b/macros/src/codegen/monotonic.rs @@ -46,6 +46,8 @@ pub fn codegen(app: &App, _analysis: &Analysis, _extra: &Extra) -> TokenStream2 #[doc(inline)] pub use #m::delay; #[doc(inline)] + pub use #m::delay_until; + #[doc(inline)] pub use #m::timeout_at; #[doc(inline)] pub use #m::timeout_after; @@ -81,6 +83,15 @@ pub fn codegen(app: &App, _analysis: &Analysis, _extra: &Extra) -> TokenStream2 DelayFuture { until, waker_storage: None } } + /// Delay until a specific time + #[inline(always)] + #[allow(non_snake_case)] + pub fn delay_until(instant: ::Instant) + -> DelayFuture { + let until = instant; + DelayFuture { until, waker_storage: None } + } + /// Delay future. #[allow(non_snake_case)] #[allow(non_camel_case_types)]