From 6fe47ff682f7123861ccc1d5cdbcf65f264ad7cc Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 10 Sep 2023 03:41:18 +0200 Subject: [PATCH] fix: receive and return a runtime handle --- src/api/controller.rs | 2 +- src/instance.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/controller.rs b/src/api/controller.rs index d7f3874..d844306 100644 --- a/src/api/controller.rs +++ b/src/api/controller.rs @@ -75,7 +75,7 @@ pub trait Controller : Sized + Send + Sync { /// important for proper cleanup fn callback( self: &Arc, - rt: &tokio::runtime::Runtime, + rt: &tokio::runtime::Handle, mut stop: tokio::sync::mpsc::UnboundedReceiver<()>, mut cb: F ) where diff --git a/src/instance.rs b/src/instance.rs index 3ffa606..aaf8bd6 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -127,7 +127,7 @@ pub mod a_sync { pub mod sync { use std::sync::{Mutex, Arc}; - use tokio::runtime::Runtime; + use tokio::runtime::{Runtime, Handle}; use crate::{ client::Client, Error, @@ -166,7 +166,7 @@ pub mod sync { } /// return a reference to contained tokio runtime, to spawn tasks on - pub fn rt(&self) -> &Runtime { &self.runtime } + pub fn rt(&self) -> &Handle { &self.runtime.handle() } /// connect and store a client session, threadsafe and sync version of [crate::Client::new] pub fn connect(&self, addr: &str) -> Result<(), Error> {