mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-07 10:37:46 +02:00
startup: Add spinloop until daemon is ready
This commit is contained in:
parent
6a605f1d08
commit
918bf9c70a
7 changed files with 17 additions and 8 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue