startup: Add spinloop until daemon is ready

This commit is contained in:
DashieTM 2024-06-04 23:37:15 +02:00
parent 6a605f1d08
commit 918bf9c70a
7 changed files with 17 additions and 8 deletions

View file

@ -1,3 +1,6 @@
use std::hint::{self};
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
@ -71,8 +74,12 @@ async fn daemon_check() {
let res: Result<(), Error> = proxy.method_call(BASE, "RegisterClient", ("ReSet",));
res
});
let ready = Arc::new(AtomicBool::new(false));
let res = handle.join();
if res.unwrap().is_err() {
run_daemon().await;
run_daemon(Some(ready.clone())).await;
}
while !ready.load(std::sync::atomic::Ordering::SeqCst) {
hint::spin_loop();
}
}