From 9a736c5eb95c01ac9dce1d1d928773f5e98be030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Mon, 31 Jan 2022 00:04:56 +1300 Subject: [PATCH] Use newly &self Supervisor.wait to drop wait loop --- lib/src/action/process_holder.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/src/action/process_holder.rs b/lib/src/action/process_holder.rs index 2089dc1..5b8f08f 100644 --- a/lib/src/action/process_holder.rs +++ b/lib/src/action/process_holder.rs @@ -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}; @@ -43,17 +43,9 @@ impl ProcessHolder { } pub async fn wait(&self) -> Result<(), RuntimeError> { - // Loop to allow concurrent operations while waiting - loop { - 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(()); - } + if let Some(p) = self.0.read().await.as_ref() { + p.wait().await?; } + Ok(()) } }