From 8743ce1c3acfe2f330264bf465b30439f1809543 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 21 Jun 2023 20:42:51 +0000 Subject: [PATCH] add time out to wait to avoid deadlock Signed-off-by: Ian Chen --- src/systems/sensors/Sensors.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/systems/sensors/Sensors.cc b/src/systems/sensors/Sensors.cc index 4790345300..591d28b225 100644 --- a/src/systems/sensors/Sensors.cc +++ b/src/systems/sensors/Sensors.cc @@ -280,12 +280,15 @@ void SensorsPrivate::RunOnce() { { std::unique_lock cvLock(this->renderMutex); - this->renderCv.wait(cvLock, [this]() + this->renderCv.wait_for(cvLock, std::chrono::microseconds(1000), [this]() { return !this->running || this->updateAvailable; }); } + if (!this->updateAvailable) + return; + if (!this->running) return;