FIX: fixed automated deletion of tracks after time

This commit is contained in:
Henry Winkel
2024-03-14 18:23:21 +01:00
parent 671f763f45
commit e039b36ed5
2 changed files with 8 additions and 8 deletions

View File

@@ -113,16 +113,16 @@ namespace TrackList
void TrackList::checkTrackStore() void TrackList::checkTrackStore()
{ {
std::lock_guard<std::mutex> lock(mx_); std::lock_guard<std::mutex> lock(mx_);
for (auto [key, value] : TrackStore_)
for (auto iter = TrackStore_.begin(); iter != TrackStore_.end();)
{ {
// value->getSensorTrackMessage()
if(value->getLastUpdateTime() >= std::chrono::system_clock::now() + std::chrono::seconds(trackNoUpdateTime)) if(duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - iter->second->getLastUpdateTime()).count() >= trackNoUpdateTime)
{ {
auto it = TrackStore_.find(key); iter = TrackStore_.erase(iter);
TrackStore_.erase(it); }else {
iter++;
} }
} }

View File

@@ -244,7 +244,7 @@ SCENARIO("Testing the SimCore SensorManager with local sensors")
std::this_thread::sleep_for(std::chrono::milliseconds(10000)); std::this_thread::sleep_for(std::chrono::milliseconds(10000));
REQUIRE(SensorManager_->getTrackListUpdateRaw()->getSensors().at(0).getTracksCount() == 0); REQUIRE(SensorManager_->getSensorListAsVector().at(0)->TrackStore.getSize() == 0);
SensorManager_->stop(); SensorManager_->stop();