Add run_for in Rust SimulatedEventLoop
Change-Id: Icf23a9c834f11ff78dbcde0b0ff3c31519767c92
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/simulated_event_loop.rs b/aos/events/simulated_event_loop.rs
index 90c4c86..0677efb 100644
--- a/aos/events/simulated_event_loop.rs
+++ b/aos/events/simulated_event_loop.rs
@@ -1,4 +1,4 @@
-use std::{marker::PhantomData, pin::Pin, ptr};
+use std::{marker::PhantomData, pin::Pin, ptr, time::Duration};
use autocxx::WithinBox;
use cxx::UniquePtr;
@@ -107,6 +107,15 @@
self.as_mut().Run();
}
+ pub fn run_for(&mut self, duration: Duration) {
+ self.as_mut().RunFor(
+ duration
+ .as_nanos()
+ .try_into()
+ .expect("Out of range: Internal clock uses 64 bits"),
+ );
+ }
+
// TODO(Brian): Expose OnStartup. Just take a callback for creating things, and rely on
// dropping the created objects instead of OnShutdown.
// pub fn spawn_on_startup(&mut self, spawner: impl FnMut());