fix: receive and return a runtime handle

This commit is contained in:
əlemi 2023-09-10 03:41:18 +02:00
parent 4ec99bab36
commit 6fe47ff682
2 changed files with 3 additions and 3 deletions

View file

@ -75,7 +75,7 @@ pub trait Controller<T : Sized + Send + Sync> : Sized + Send + Sync {
/// important for proper cleanup /// important for proper cleanup
fn callback<F>( fn callback<F>(
self: &Arc<Self>, self: &Arc<Self>,
rt: &tokio::runtime::Runtime, rt: &tokio::runtime::Handle,
mut stop: tokio::sync::mpsc::UnboundedReceiver<()>, mut stop: tokio::sync::mpsc::UnboundedReceiver<()>,
mut cb: F mut cb: F
) where ) where

View file

@ -127,7 +127,7 @@ pub mod a_sync {
pub mod sync { pub mod sync {
use std::sync::{Mutex, Arc}; use std::sync::{Mutex, Arc};
use tokio::runtime::Runtime; use tokio::runtime::{Runtime, Handle};
use crate::{ use crate::{
client::Client, Error, client::Client, Error,
@ -166,7 +166,7 @@ pub mod sync {
} }
/// return a reference to contained tokio runtime, to spawn tasks on /// 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] /// connect and store a client session, threadsafe and sync version of [crate::Client::new]
pub fn connect(&self, addr: &str) -> Result<(), Error> { pub fn connect(&self, addr: &str) -> Result<(), Error> {