mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
Fix busy loop (#14839)
* refactor(tauri-cli): remove unneeded Arc<Mutex> * fix(tauri-cli): remove busy-looping
This commit is contained in:
@@ -16,7 +16,6 @@ pub use rust::{MobileOptions, Options, Rust as AppInterface, WatcherOptions};
|
||||
|
||||
pub trait DevProcess {
|
||||
fn kill(&self) -> std::io::Result<()>;
|
||||
fn try_wait(&self) -> std::io::Result<Option<ExitStatus>>;
|
||||
#[allow(unused)]
|
||||
fn wait(&self) -> std::io::Result<ExitStatus>;
|
||||
#[allow(unused)]
|
||||
|
||||
@@ -514,9 +514,7 @@ impl Rust {
|
||||
run: F,
|
||||
dirs: &Dirs,
|
||||
) -> crate::Result<()> {
|
||||
let child = run(self, config)?;
|
||||
|
||||
let process = Arc::new(Mutex::new(child));
|
||||
let mut child = run(self, config)?;
|
||||
let (tx, rx) = sync_channel(1);
|
||||
|
||||
let watch_folders = get_watch_folders(additional_watch_folders, dirs.tauri)?;
|
||||
@@ -581,17 +579,12 @@ impl Rust {
|
||||
display_path(event_path.strip_prefix(dirs.frontend).unwrap_or(event_path))
|
||||
);
|
||||
|
||||
let mut p = process.lock().unwrap();
|
||||
p.kill().context("failed to kill app process")?;
|
||||
child.kill().context("failed to kill app process")?;
|
||||
|
||||
// wait for the process to exit
|
||||
// note that on mobile, kill() already waits for the process to exit (duct implementation)
|
||||
loop {
|
||||
if !matches!(p.try_wait(), Ok(None)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*p = run(self, config)?;
|
||||
let _ = child.wait();
|
||||
child = run(self, config)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,6 @@ impl DevProcess for DevChild {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn try_wait(&self) -> std::io::Result<Option<ExitStatus>> {
|
||||
self.dev_child.try_wait()
|
||||
}
|
||||
|
||||
fn wait(&self) -> std::io::Result<ExitStatus> {
|
||||
self.dev_child.wait()
|
||||
}
|
||||
|
||||
@@ -72,10 +72,6 @@ impl DevProcess for DevChild {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn try_wait(&self) -> std::io::Result<Option<ExitStatus>> {
|
||||
self.child.try_wait().map(|res| res.map(|o| o.status))
|
||||
}
|
||||
|
||||
fn wait(&self) -> std::io::Result<ExitStatus> {
|
||||
self.child.wait().map(|o| o.status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user