Update iface_rt
behaviour to fix tokio update
This commit is contained in:
parent
178abf5a72
commit
52d34e42a1
@ -132,7 +132,7 @@ macro_rules! handle_iface {
|
||||
($m:ident, |$data:ident| $($f:tt)+) => {move |$m| tokio::task::block_in_place(move || {
|
||||
let $data = $m.path.get_data();
|
||||
// Run a Future on the dedicated tokio runtime
|
||||
iface_rt_handle().block_on(async move {
|
||||
iface_rt().block_on(async move {
|
||||
$($f)+
|
||||
})
|
||||
})};
|
||||
|
@ -12,38 +12,26 @@ mod ifaces;
|
||||
|
||||
const DBUS_NAME: &'static str = "org.ddnss.sfs.mc";
|
||||
// Interface tokio runtime
|
||||
static mut IFACE_RT: Option<tokio::runtime::Runtime> = None;
|
||||
static mut IFACE_RT_HANDLE: Option<Arc<tokio::runtime::Handle>> = None;
|
||||
static mut IFACE_RT: Option<Arc<tokio::runtime::Runtime>> = None;
|
||||
static IFACE_RT_INIT: std::sync::Once = std::sync::Once::new();
|
||||
|
||||
fn iface_name(iface: &str) -> String {
|
||||
DBUS_NAME.to_owned() + "." + iface
|
||||
}
|
||||
|
||||
fn iface_rt_handle() -> Arc<tokio::runtime::Handle> {
|
||||
fn iface_rt() -> Arc<tokio::runtime::Runtime> {
|
||||
IFACE_RT_INIT.call_once(|| {
|
||||
unsafe {
|
||||
IFACE_RT = Some(tokio::runtime::Builder::new()
|
||||
IFACE_RT = Some(Arc::new(tokio::runtime::Builder::new_multi_thread()
|
||||
.thread_name("iface-runtime-worker")
|
||||
.build()
|
||||
.unwrap()
|
||||
);
|
||||
|
||||
IFACE_RT_HANDLE = match &IFACE_RT {
|
||||
Some(iface_rt) => Some(Arc::new(iface_rt
|
||||
.handle()
|
||||
.clone()
|
||||
)),
|
||||
_ => unreachable!()
|
||||
};
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
unsafe {
|
||||
match &IFACE_RT_HANDLE {
|
||||
Some(iface_rt_handle) => iface_rt_handle.clone(),
|
||||
_ => unreachable!()
|
||||
}
|
||||
IFACE_RT.clone().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user