mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[traffic] Update clear/purge logic to use update mechanism
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -157,7 +157,6 @@ void TrafficManager::Clear()
|
||||
#endif
|
||||
m_messageCache.clear();
|
||||
m_feedQueue.clear();
|
||||
m_allMwmColoring.clear();
|
||||
m_mwmCache.clear();
|
||||
|
||||
// TODO figure out which of the ones below we still need
|
||||
@@ -411,6 +410,12 @@ void TrafficManager::Push(traffxml::TraffFeed feed)
|
||||
}
|
||||
|
||||
void TrafficManager::PurgeExpiredMessages()
|
||||
{
|
||||
PurgeExpiredMessagesImpl();
|
||||
OnTrafficDataUpdate();
|
||||
}
|
||||
|
||||
void TrafficManager::PurgeExpiredMessagesImpl()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
LOG(LINFO, ("before:", m_messageCache.size(), "message(s)"));
|
||||
@@ -549,7 +554,7 @@ void TrafficManager::ThreadRoutine()
|
||||
if (steady_clock::now() - lastPurged >= kPurgeInterval)
|
||||
{
|
||||
lastPurged == steady_clock::now();
|
||||
PurgeExpiredMessages();
|
||||
PurgeExpiredMessagesImpl();
|
||||
}
|
||||
|
||||
LOG(LINFO, ("active MWMs changed:", m_activeMwmsChanged, ", poll needed:", m_isPollNeeded));
|
||||
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
/**
|
||||
* @brief Purges expired messages from the cache.
|
||||
*
|
||||
* This method is safe to call from any thread.
|
||||
* This method is safe to call from any thread, except for the traffic worker thread.
|
||||
*/
|
||||
void PurgeExpiredMessages();
|
||||
|
||||
@@ -352,6 +352,15 @@ private:
|
||||
*/
|
||||
bool Poll();
|
||||
|
||||
/**
|
||||
* @brief Purges expired messages from the cache.
|
||||
*
|
||||
* This is the internal conterpart of `PurgeExpiredMessages()`. It is safe to call from any
|
||||
* thread. Unlike `PurgeExpiredMessages()`, it does not wake the worker thread, making it suitable
|
||||
* for use on the worker thread.
|
||||
*/
|
||||
void PurgeExpiredMessagesImpl();
|
||||
|
||||
/**
|
||||
* @brief Consolidates the feed queue.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user