diff --git a/src/lib.rs b/src/lib.rs index 7a3e843..ccbc229 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,11 +41,11 @@ pub trait Controller : Sized + Send + Sync { async fn send(&self, x: Self::Input) -> Result<(), Error>; async fn recv(&self) -> Result; - fn callback(self: Arc, mut cb: F) + fn callback(self: Arc, rt: &tokio::runtime::Runtime, mut cb: F) where Self : 'static, F : FnMut(T) + Sync + Send + 'static { let x = Arc::new(self); - tokio::spawn(async move { + rt.spawn(async move { while let Ok(data) = x.recv().await { cb(data) }