Skip to content

Commit

Permalink
startup: Add spinloop until daemon is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Jun 4, 2024
1 parent 6a605f1 commit 918bf9c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .direnv/flake-profile
1 change: 0 additions & 1 deletion .direnv/flake-profile-10-link

This file was deleted.

1 change: 1 addition & 0 deletions .direnv/flake-profile-11-link
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository = "https://github.com/Xetibo/ReSet"
license = "GPL-3.0-or-later"

[dependencies]
reset_daemon = "1.5.0"
reset_daemon = "2.1.0"
re_set-lib = "5.2.1"
# re_set-lib = { git = "https://github.com/Xetibo/ReSet-Lib" }
adw = { version = "0.6.0", package = "libadwaita", features = ["v1_4"] }
Expand Down
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
# (rust-bin.selectLatestNightlyWith
# (toolchain: toolchain.default))
rust-bin.nightly."2024-05-10".default
rust-analyzer
clippy
];
};

Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::hint::{self};
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::thread;
use std::time::Duration;

Expand Down Expand Up @@ -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();
}
}

0 comments on commit 918bf9c

Please sign in to comment.