Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Use `tokio::time::sleep` instead of blocking threads
Sebastian Martinez committed 1 year ago
commit e0323e34bc7b395d02b6e97366c54441bbcd86f7
parent 0693f4f806eaad431fbbbf8b695b0bd26d52bb3d
3 files changed +4 -2
modified Cargo.lock
@@ -4006,6 +4006,7 @@ dependencies = [
 "tauri-plugin-shell",
 "tauri-plugin-window-state",
 "thiserror",
+
 "tokio",
 "ts-rs",
]

modified crates/radicle-tauri/Cargo.toml
@@ -31,6 +31,7 @@ tauri-plugin-shell = { version = "2.0.1" }
tauri-plugin-window-state = { version = "2.0.1" }
thiserror = { version = "1.0.64" }
ts-rs = { version = "10.0.0", features = ["serde-json-impl", "no-serde-warnings"] }
+
tokio = { version = "1.40.0", features = ["time"] }

[features]
# by default Tauri runs in production mode
modified crates/radicle-tauri/src/lib.rs
@@ -45,7 +45,7 @@ pub fn run() {
            tauri::async_runtime::spawn(async move {
                loop {
                    let _ = node_handler.emit("node_running", node_status.is_running());
-
                    std::thread::sleep(std::time::Duration::from_secs(2));
+
                    tokio::time::sleep(std::time::Duration::from_secs(2)).await;
                }
            });

@@ -61,7 +61,7 @@ pub fn run() {
                        log::debug!("node: event subscription loop has exited.");
                    }

-
                    std::thread::sleep(std::time::Duration::from_secs(2));
+
                    tokio::time::sleep(std::time::Duration::from_secs(2)).await;
                }
            });