diff --git a/map/traffic_manager.cpp b/map/traffic_manager.cpp index d12b5f7b5e..4030587493 100644 --- a/map/traffic_manager.cpp +++ b/map/traffic_manager.cpp @@ -378,7 +378,7 @@ void TrafficManager::OnTrafficDataResponse(traffic::TrafficInfo && info) size_t const dataSize = info.GetColoring().size() * kElementSize; m_currentCacheSizeBytes += (dataSize - it->second.m_dataSize); it->second.m_dataSize = dataSize; - CheckCacheSize(); + ShrinkCacheToAllowableSize(); } UpdateState(); @@ -399,7 +399,7 @@ void TrafficManager::UniteActiveMwms(set & activeMwms) const activeMwms.insert(m_activeRoutingMwms.cbegin(), m_activeRoutingMwms.cend()); } -void TrafficManager::CheckCacheSize() +void TrafficManager::ShrinkCacheToAllowableSize() { // Calculating number of different active mwms. set activeMwms; diff --git a/map/traffic_manager.hpp b/map/traffic_manager.hpp index ffef9de631..dbb984b2d5 100644 --- a/map/traffic_manager.hpp +++ b/map/traffic_manager.hpp @@ -15,6 +15,7 @@ #include "base/thread.hpp" +#include "std/algorithm.hpp" #include "std/atomic.hpp" #include "std/chrono.hpp" #include "std/map.hpp" @@ -105,6 +106,11 @@ private: void OnTrafficDataResponse(traffic::TrafficInfo && info); void OnTrafficRequestFailed(traffic::TrafficInfo && info); + /// \brief Updates |activeMwms| and request traffic data. + /// \param rect is a rectangle covering a new active mwm set. + /// \note |lastMwmsByRect|/|activeMwms| may be either |m_lastDrapeMwmsByRect/|m_activeDrapeMwms| + /// or |m_lastRoutingMwmsByRect|/|m_activeRoutingMwms|. + /// \note |m_mutex| is locked inside the method. So the method should be called without |m_mutex|. void UpdateActiveMwms(m2::RectD const & rect, vector & lastMwmsByRect, set & activeMwms); @@ -114,7 +120,7 @@ private: void Clear(); void ClearCache(MwmSet::MwmId const & mwmId); - void CheckCacheSize(); + void ShrinkCacheToAllowableSize(); void UpdateState(); void ChangeState(TrafficState newState); @@ -129,8 +135,7 @@ private: { set activeMwms; UniteActiveMwms(activeMwms); - for (auto const & mwmId : activeMwms) - f(mwmId); + for_each(activeMwms.begin(), activeMwms.end(), forward(f)); } GetMwmsByRectFn m_getMwmsByRectFn;