mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-04 03:43:46 +00:00
[traffic] Fix Push() and make it public for testing
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -372,9 +372,12 @@ bool TrafficManager::Poll()
|
||||
|
||||
void TrafficManager::Push(traffxml::TraffFeed feed)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_feedQueue.push_back(feed);
|
||||
// TODO should we update m_lastResponseTime?
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_feedQueue.push_back(feed);
|
||||
// TODO should we update m_lastResponseTime?
|
||||
}
|
||||
m_condition.notify_one();
|
||||
}
|
||||
|
||||
void TrafficManager::ConsolidateFeedQueue()
|
||||
@@ -591,7 +594,7 @@ bool TrafficManager::WaitForRequest()
|
||||
LOG(LINFO, ("nothing to do for now, waiting for timeout or notification"));
|
||||
bool const timeout = !m_condition.wait_for(lock, kUpdateInterval, [this]
|
||||
{
|
||||
return !m_isRunning || (m_activeMwmsChanged && !IsTestMode());
|
||||
return !m_isRunning || (m_activeMwmsChanged && !IsTestMode()) || !m_feedQueue.empty();
|
||||
});
|
||||
|
||||
// check again if we got terminated while waiting (or woken up because we got terminated)
|
||||
|
||||
@@ -204,6 +204,17 @@ public:
|
||||
*/
|
||||
void SetTestMode();
|
||||
|
||||
/**
|
||||
* @brief Processes a traffic feed received through a push operation.
|
||||
*
|
||||
* Push is safe to call from any thread.
|
||||
*
|
||||
* Push operations are not supported on all platforms.
|
||||
*
|
||||
* @param feed The traffic feed.
|
||||
*/
|
||||
void Push(traffxml::TraffFeed feed);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Holds information about pending or previous traffic requests pertaining to an MWM.
|
||||
@@ -313,17 +324,6 @@ private:
|
||||
*/
|
||||
bool Poll();
|
||||
|
||||
/**
|
||||
* @brief Processes a traffic feed received through a push operation.
|
||||
*
|
||||
* Push is safe to call from any thread.
|
||||
*
|
||||
* Push operations are not supported on all platforms.
|
||||
*
|
||||
* @param feed The traffic feed.
|
||||
*/
|
||||
void Push(traffxml::TraffFeed feed);
|
||||
|
||||
/**
|
||||
* @brief Consolidates the feed queue.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user