mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
Use newly &self Supervisor.wait to drop wait loop
This commit is contained in:
parent
995d38078e
commit
9a736c5eb9
@ -1,6 +1,6 @@
|
|||||||
use std::{sync::Arc, time::Duration};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::{sync::RwLock, time::timeout};
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use crate::{command::Supervisor, error::RuntimeError, signal::process::SubSignal};
|
use crate::{command::Supervisor, error::RuntimeError, signal::process::SubSignal};
|
||||||
|
|
||||||
@ -43,17 +43,9 @@ impl ProcessHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn wait(&self) -> Result<(), RuntimeError> {
|
pub async fn wait(&self) -> Result<(), RuntimeError> {
|
||||||
// Loop to allow concurrent operations while waiting
|
if let Some(p) = self.0.read().await.as_ref() {
|
||||||
loop {
|
p.wait().await?;
|
||||||
if let Some(p) = self.0.write().await.as_mut() {
|
|
||||||
match timeout(Duration::from_millis(20), p.wait()).await {
|
|
||||||
Err(_timeout) => continue,
|
|
||||||
Ok(Err(err)) => break Err(err),
|
|
||||||
Ok(Ok(())) => break Ok(()),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break Ok(());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user