Skip to content

Commit

Permalink
add time out to wait to avoid deadlock
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <ichen@openrobotics.org>
  • Loading branch information
iche033 committed Jun 21, 2023
1 parent 001dd9b commit 8743ce1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,15 @@ void SensorsPrivate::RunOnce()
{
{
std::unique_lock<std::mutex> 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;

Expand Down

0 comments on commit 8743ce1

Please sign in to comment.