mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 06:33:42 +00:00
[traffic] Refactoring
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -322,7 +322,12 @@ void TrafficManager::OnChangeRoutingSessionState(routing::SessionState previous,
|
||||
{
|
||||
m_activeMwmsChanged = true;
|
||||
std::swap(mwms, m_activeRoutingMwms);
|
||||
RequestTrafficSubscription();
|
||||
|
||||
if ((m_activeDrapeMwms.empty() && m_activePositionMwms.empty() && m_activeRoutingMwms.empty())
|
||||
|| !IsEnabled() || IsInvalidState() || m_isPaused)
|
||||
return;
|
||||
|
||||
m_condition.notify_one();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,7 +414,12 @@ void TrafficManager::UpdateActiveMwms(m2::RectD const & rect,
|
||||
if (mwm.IsAlive())
|
||||
activeMwms.insert(mwm);
|
||||
}
|
||||
RequestTrafficSubscription();
|
||||
|
||||
if ((m_activeDrapeMwms.empty() && m_activePositionMwms.empty() && m_activeRoutingMwms.empty())
|
||||
|| !IsEnabled() || IsInvalidState() || m_isPaused)
|
||||
return;
|
||||
|
||||
m_condition.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,6 +849,8 @@ bool TrafficManager::WaitForRequest()
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO no longer needed
|
||||
#ifdef traffic_dead_code
|
||||
void TrafficManager::RequestTrafficSubscription()
|
||||
{
|
||||
if ((m_activeDrapeMwms.empty() && m_activePositionMwms.empty() && m_activeRoutingMwms.empty())
|
||||
@@ -862,8 +874,6 @@ void TrafficManager::RequestTrafficSubscription()
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO no longer needed
|
||||
#ifdef traffic_dead_code
|
||||
void TrafficManager::OnTrafficRequestFailed(traffic::TrafficInfo && info)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
@@ -498,6 +498,8 @@ private:
|
||||
|
||||
// This is a group of methods that haven't their own synchronization inside.
|
||||
|
||||
// TODO no longer needed
|
||||
#ifdef traffic_dead_code
|
||||
/**
|
||||
* @brief Requests a refresh of traffic subscriptions to match all currently active MWMs.
|
||||
*
|
||||
@@ -511,8 +513,6 @@ private:
|
||||
*/
|
||||
void RequestTrafficSubscription();
|
||||
|
||||
// TODO no longer needed
|
||||
#ifdef traffic_dead_code
|
||||
/**
|
||||
* @brief Removes traffic data for one specific MWM from the cache.
|
||||
*
|
||||
@@ -642,24 +642,20 @@ private:
|
||||
*
|
||||
* Routing MWMs are stored as a set.
|
||||
*
|
||||
* The other groups arestored twice: as a set and as a vector. The set always holds the MWMs which
|
||||
* The other groups are stored twice: as a set and as a vector. The set always holds the MWMs which
|
||||
* were last seen in use. Both get updated together when active MWMs are added or removed.
|
||||
* However, the vector is used as a reference to detect changes. It may get cleared when the set
|
||||
* is not, which is used to invalidate the set without destroying its contents.
|
||||
* However, the vector is used as a reference to detect changes. Clear() clears the vector but not
|
||||
* the set, invalidating the set without destroying its contents.
|
||||
*
|
||||
* Methods which use only the set:
|
||||
*
|
||||
* * RequestTrafficSubscription(), exits if empty, otherwise cycles through the set.
|
||||
* * OnTrafficRequestFailed(), determines if an MWM is still active and the request should be retried.
|
||||
* * UniteActiveMwms(), build the list of active MWMs (used by RequestTrafficSubscription() or to shrink the cache).
|
||||
* * UpdateState(), cycles through the set to determine the state of traffic requests (renderer only).
|
||||
* * UniteActiveMwms(), build the list of active MWMs (used by RequestTrafficSubscription()).
|
||||
*
|
||||
* Methods which use both, but in a different way:
|
||||
*
|
||||
* * (dead code) ClearCache(), removes the requested MWM from the set but clears the vector completely.
|
||||
* * UpdateActiveMwms(), uses the vector to detect changes (not for routing MWMs). If so, it updates both vector and set.
|
||||
*
|
||||
* Clear() clears both the set and the vector. (Clearing the set is currently disabled as it breaks ForEachActiveMwm.)
|
||||
* * UpdateActiveMwms(), uses the vector to detect changes (not for routing MWMs). If so, it
|
||||
* updates both vector and set, but adds MWMs to the set only if they are alive.
|
||||
*/
|
||||
std::vector<MwmSet::MwmId> m_lastDrapeMwmsByRect;
|
||||
std::set<MwmSet::MwmId> m_activeDrapeMwms;
|
||||
@@ -667,6 +663,11 @@ private:
|
||||
std::set<MwmSet::MwmId> m_activePositionMwms;
|
||||
std::set<MwmSet::MwmId> m_activeRoutingMwms;
|
||||
|
||||
/**
|
||||
* @brief Whether active MWMs have changed since the last request.
|
||||
*/
|
||||
bool m_activeMwmsChanged = false;
|
||||
|
||||
// TODO no longer needed
|
||||
#ifdef traffic_dead_code
|
||||
// The ETag or entity tag is part of HTTP, the protocol for the World Wide Web.
|
||||
@@ -726,11 +727,6 @@ private:
|
||||
*/
|
||||
std::chrono::time_point<std::chrono::steady_clock> m_lastStorageUpdate;
|
||||
|
||||
/**
|
||||
* @brief Whether active MWMs have changed since the last request.
|
||||
*/
|
||||
bool m_activeMwmsChanged = false;
|
||||
|
||||
/**
|
||||
* @brief Whether a poll operation is needed.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user