blob: 3b9c83da96da190f2b3009e66f543253bde6310e [file] [log] [blame]
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +02001#include "sensor_cache.hpp"
2
3SensorCache::SensorsContainer::iterator SensorCache::findExpiredSensor(
4 SensorCache::SensorsContainer::iterator begin)
5{
6 return std::find_if(begin, sensors.end(),
7 [](const auto& item) { return item.second.expired(); });
8}
9
10void SensorCache::cleanupExpiredSensors()
11{
12 auto begin = sensors.begin();
13
14 for (auto it = findExpiredSensor(begin); it != sensors.end();
15 it = findExpiredSensor(begin))
16 {
17 begin = sensors.erase(it);
18 }
19}