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 | { |
Patrick Williams | 583ba44 | 2025-02-03 14:28:19 -0500 | [diff] [blame^] | 6 | return std::find_if(begin, sensors.end(), [](const auto& item) { |
| 7 | return item.second.expired(); |
| 8 | }); |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | void SensorCache::cleanupExpiredSensors() |
| 12 | { |
| 13 | auto begin = sensors.begin(); |
| 14 | |
| 15 | for (auto it = findExpiredSensor(begin); it != sensors.end(); |
| 16 | it = findExpiredSensor(begin)) |
| 17 | { |
| 18 | begin = sensors.erase(it); |
| 19 | } |
| 20 | } |