Create sweep mutex to eliminate race condition between ComputeSweep() and UpdateSweep()

This commit is contained in:
Dan Paulat 2022-04-03 19:19:14 -05:00
parent b2fbfa0dee
commit 4c6a40140b
4 changed files with 26 additions and 5 deletions

View file

@ -148,8 +148,6 @@ void RadarProductLayer::UpdateSweep()
{
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdateSweep()";
p->sweepNeedsUpdate_ = false;
gl::OpenGLFunctions& gl = context()->gl_;
boost::timer::cpu_timer timer;
@ -157,6 +155,17 @@ void RadarProductLayer::UpdateSweep()
std::shared_ptr<view::RadarProductView> radarProductView =
context()->radarProductView_;
std::unique_lock sweepLock(radarProductView->sweep_mutex(),
std::try_to_lock);
if (!sweepLock.owns_lock())
{
BOOST_LOG_TRIVIAL(debug)
<< logPrefix_ << "Sweep locked, deferring update";
return;
}
p->sweepNeedsUpdate_ = false;
const std::vector<float>& vertices = radarProductView->vertices();
// Bind a vertex array object