From b2c576ba7fb8d9707b12b0c35afe14b081fad2fa Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 7 Jul 2023 13:44:17 -0700 Subject: [PATCH] add time out to wait to avoid deadlock (#2025) 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 388fcbf953..a346076f6d 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;