Pass the EventLoopRuntime by value
Now that the EventLoopRuntime simply wraps a &CppEventLoopRuntime,
we can make give the spawned task an owned EventLoopRuntime. This means
that the spawned future can now own and use the EventLoopRuntime within it.
This is safe because as long as the EventLoop exists, so does the
CppEventLoopRuntime.
Change-Id: Iccaa6373fdb9d61a7995758f7b99906275f18c99
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/pong.rs b/aos/events/pong.rs
index d030dc7..34da238 100644
--- a/aos/events/pong.rs
+++ b/aos/events/pong.rs
@@ -19,14 +19,14 @@
aos_init::init();
let config = config::read_config_from(Path::new("pingpong_config.json")).unwrap();
ShmEventLoop::new(&config).run_with(|runtime| {
- let task = pong(runtime);
+ let task = pong(*runtime);
runtime.set_realtime_priority(5);
runtime.spawn(task);
});
}
/// Responds to ping messages with an equivalent pong.
-async fn pong(event_loop: &EventLoopRuntime<'_>) -> Never {
+async fn pong(event_loop: EventLoopRuntime<'_>) -> Never {
// The watcher gives us incoming ping messages.
let mut ping_watcher: Watcher<ping::Ping> = event_loop.make_watcher("/test").unwrap();