mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-20 19:44:50 +00:00
feat: unified and more comprehensive xrservice alive detection
This commit is contained in:
parent
5494306ac2
commit
665242aa28
2 changed files with 17 additions and 10 deletions
|
@ -357,10 +357,10 @@ impl SimpleComponent for App {
|
|||
Msg::ClockTicking => {
|
||||
self.main_view.sender().emit(MainViewMsg::ClockTicking);
|
||||
let should_poll_for_devices = self.xrservice_ready
|
||||
&& self.xrservice_worker.as_ref().is_some_and(|w| {
|
||||
let state = w.state.lock().unwrap();
|
||||
state.exit_status.is_none() && !state.stop_requested
|
||||
});
|
||||
&& self
|
||||
.xrservice_worker
|
||||
.as_ref()
|
||||
.is_some_and(JobWorker::is_alive);
|
||||
if should_poll_for_devices {
|
||||
if let Some(monado) = self.libmonado.as_ref() {
|
||||
self.xr_devices = XRDevice::from_libmonado(monado);
|
||||
|
@ -722,15 +722,17 @@ impl SimpleComponent for App {
|
|||
self.xrservice_ready = success;
|
||||
self.main_view
|
||||
.sender()
|
||||
.emit(MainViewMsg::UpdateXrServiceReady(success));
|
||||
if success {
|
||||
self.run_autostart(sender.clone());
|
||||
} else if self
|
||||
.emit(MainViewMsg::UpdateXrServiceReady(true));
|
||||
if self
|
||||
.xrservice_worker
|
||||
.as_ref()
|
||||
.is_some_and(|w| w.exit_code().is_none())
|
||||
.is_some_and(JobWorker::is_alive)
|
||||
{
|
||||
sender.input(Msg::StartProber);
|
||||
if success {
|
||||
self.run_autostart(sender.clone());
|
||||
} else {
|
||||
sender.input(Msg::StartProber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,4 +123,9 @@ impl JobWorker {
|
|||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_alive(&self) -> bool {
|
||||
let state = self.state.lock().unwrap();
|
||||
!state.stop_requested && state.started && !state.exited && state.exit_status.is_none()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue