Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 1 | #include "sensor_cache.hpp" |
| 2 | |
| 3 | SensorCache::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 | |
| 10 | void 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 | } |