ROGCC: Use tokio instead of smol

This commit is contained in:
Luke D. Jones
2022-11-07 09:00:46 +13:00
parent 37553a5fdd
commit efc752cce6
6 changed files with 78 additions and 91 deletions

View File

@@ -1,12 +1,12 @@
use eframe::NativeOptions;
use rog_aura::layouts::KeyLayout;
use rog_control_center::{
error::Result,
config::Config, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
config::Config, error::Result, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
page_states::PageDataStates, print_versions, startup_error::AppErrorShow, RogApp,
RogDbusClientBlocking, SHOWING_GUI, SHOW_GUI,
};
use rog_platform::supported::SupportedFunctions;
use tokio::runtime::Runtime;
use std::{
fs::OpenOptions,
@@ -24,6 +24,11 @@ const BOARD_NAME: &str = "/sys/class/dmi/id/board_name";
fn main() -> Result<()> {
print_versions();
// start tokio
let rt = Runtime::new().expect("Unable to create Runtime");
// Enter the runtime so that `tokio::spawn` is available immediately.
let _enter = rt.enter();
let native_options = eframe::NativeOptions {
vsync: true,
decorated: true,
@@ -88,7 +93,9 @@ fn main() -> Result<()> {
Err(_) => on_tmp_dir_exists().unwrap(),
};
let states = setup_page_state_and_notifs(layout.clone(), &config, native_options.clone(), &dbus).unwrap();
let states =
setup_page_state_and_notifs(layout.clone(), &config, native_options.clone(), &dbus)
.unwrap();
loop {
if !start_closed {
@@ -110,6 +117,11 @@ fn main() -> Result<()> {
}
}
}
// loop {
// // This is just a blocker to idle and ensure the reator reacts
// sleep(Duration::from_millis(1000)).await;
// }
Ok(())
}
@@ -165,10 +177,7 @@ fn setup_page_state_and_notifs(
)
}
fn start_app(
states: PageDataStates,
native_options: NativeOptions,
) -> Result<()> {
fn start_app(states: PageDataStates, native_options: NativeOptions) -> Result<()> {
let mut ipc_file = get_ipc_file().unwrap();
ipc_file.write_all(&[SHOWING_GUI]).unwrap();
eframe::run_native(