mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
[traffic] Keep polling and processing messages while routing
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -259,7 +259,7 @@ void TrafficManager::OnChangeRoutingSessionState(routing::SessionState previous,
|
|||||||
std::swap(mwms, m_activeRoutingMwms);
|
std::swap(mwms, m_activeRoutingMwms);
|
||||||
|
|
||||||
if ((m_activeDrapeMwms.empty() && m_activePositionMwms.empty() && m_activeRoutingMwms.empty())
|
if ((m_activeDrapeMwms.empty() && m_activePositionMwms.empty() && m_activeRoutingMwms.empty())
|
||||||
|| !IsEnabled() || IsInvalidState() || m_isPaused)
|
|| !IsEnabled() || IsInvalidState() || IsPausedAndNotRouting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_condition.notify_one();
|
m_condition.notify_one();
|
||||||
@@ -269,7 +269,7 @@ void TrafficManager::OnChangeRoutingSessionState(routing::SessionState previous,
|
|||||||
|
|
||||||
void TrafficManager::RecalculateSubscription(bool forceRenewal)
|
void TrafficManager::RecalculateSubscription(bool forceRenewal)
|
||||||
{
|
{
|
||||||
if (!IsEnabled() || m_isPaused)
|
if (!IsEnabled() || IsPausedAndNotRouting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_currentModelView.second)
|
if (m_currentModelView.second)
|
||||||
@@ -367,7 +367,7 @@ void TrafficManager::UpdateActiveMwms(m2::RectD const & rect, std::vector<MwmSet
|
|||||||
activeMwms.insert(mwm);
|
activeMwms.insert(mwm);
|
||||||
|
|
||||||
if ((m_activeDrapeMwms.empty() && m_activePositionMwms.empty() && m_activeRoutingMwms.empty())
|
if ((m_activeDrapeMwms.empty() && m_activePositionMwms.empty() && m_activeRoutingMwms.empty())
|
||||||
|| !IsEnabled() || IsInvalidState() || m_isPaused)
|
|| !IsEnabled() || IsInvalidState() || IsPausedAndNotRouting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_condition.notify_one();
|
m_condition.notify_one();
|
||||||
@@ -381,7 +381,7 @@ void TrafficManager::UpdateMyPosition(MyPosition const & myPosition)
|
|||||||
double const kSquareSideM = 5000.0;
|
double const kSquareSideM = 5000.0;
|
||||||
m_currentPosition = {myPosition, true /* initialized */};
|
m_currentPosition = {myPosition, true /* initialized */};
|
||||||
|
|
||||||
if (!IsEnabled() || IsInvalidState() || m_isPaused)
|
if (!IsEnabled() || IsInvalidState() || IsPausedAndNotRouting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m2::RectD const rect = mercator::RectByCenterXYAndSizeInMeters(myPosition.m_position, kSquareSideM / 2.0);
|
m2::RectD const rect = mercator::RectByCenterXYAndSizeInMeters(myPosition.m_position, kSquareSideM / 2.0);
|
||||||
@@ -393,7 +393,7 @@ void TrafficManager::UpdateViewport(ScreenBase const & screen)
|
|||||||
{
|
{
|
||||||
m_currentModelView = {screen, true /* initialized */};
|
m_currentModelView = {screen, true /* initialized */};
|
||||||
|
|
||||||
if (!IsEnabled() || IsInvalidState() || m_isPaused)
|
if (!IsEnabled() || IsInvalidState() || IsPausedAndNotRouting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (df::GetZoomLevel(screen.GetScale()) < df::kRoadClass0ZoomLevel)
|
if (df::GetZoomLevel(screen.GetScale()) < df::kRoadClass0ZoomLevel)
|
||||||
@@ -669,7 +669,7 @@ void TrafficManager::ThreadRoutine()
|
|||||||
|
|
||||||
while (WaitForRequest())
|
while (WaitForRequest())
|
||||||
{
|
{
|
||||||
if (!IsEnabled() || m_isPaused)
|
if (!IsEnabled() || IsPausedAndNotRouting())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -733,7 +733,7 @@ bool TrafficManager::WaitForRequest()
|
|||||||
if (!m_isRunning)
|
if (!m_isRunning)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (IsEnabled() && !m_isPaused)
|
if (IsEnabled() && !IsPausedAndNotRouting())
|
||||||
{
|
{
|
||||||
// if we have feeds in the queue, return immediately
|
// if we have feeds in the queue, return immediately
|
||||||
if (!m_feedQueue.empty())
|
if (!m_feedQueue.empty())
|
||||||
|
|||||||
@@ -492,13 +492,14 @@ private:
|
|||||||
*
|
*
|
||||||
* Upon creation, the traffic manager is not paused.
|
* Upon creation, the traffic manager is not paused.
|
||||||
*
|
*
|
||||||
* While paused, the traffic manager will not update its subscription area (upon being enabled
|
* While the traffic manager is paused and no route is active, the traffic manager will not update
|
||||||
* again, it will do so if necessary). It will not poll any sources or process any messages. Feeds
|
* its subscription area (upon resuming, it will do so if necessary). It will not poll any sources
|
||||||
* added via `ReceiveFeed()` will be added to the queue but will not be processed until the
|
* or process any messages. Feeds added via `ReceiveFeed()` will be added to the queue but will
|
||||||
* traffic manager is resumed.
|
* not be processed until the traffic manager is resumed.
|
||||||
*
|
*
|
||||||
* Pausing and resuming is similar in effect to disabling and enabling the traffic manager, except
|
* Pausing and resuming is similar in effect to disabling and enabling the traffic manager, except
|
||||||
* it does not change the external state. It is intended for internal use by the framework.
|
* it does not change the external state, and an active route effectively overrides the paused
|
||||||
|
* state. It is intended for internal use by the framework.
|
||||||
*/
|
*/
|
||||||
void Pause();
|
void Pause();
|
||||||
|
|
||||||
@@ -513,7 +514,8 @@ private:
|
|||||||
* received before or while the traffic manager was paused.
|
* received before or while the traffic manager was paused.
|
||||||
*
|
*
|
||||||
* Pausing and resuming is similar in effect to disabling and enabling the traffic manager, except
|
* Pausing and resuming is similar in effect to disabling and enabling the traffic manager, except
|
||||||
* it does not change the external state. It is intended for internal use by the framework.
|
* it does not change the external state, and an active route effectively overrides the paused
|
||||||
|
* state. It is intended for internal use by the framework.
|
||||||
*/
|
*/
|
||||||
void Resume();
|
void Resume();
|
||||||
|
|
||||||
@@ -547,6 +549,18 @@ private:
|
|||||||
bool IsObserverInhibited() const { return (m_routingSessionState == routing::SessionState::RouteBuilding)
|
bool IsObserverInhibited() const { return (m_routingSessionState == routing::SessionState::RouteBuilding)
|
||||||
|| (m_routingSessionState == routing::SessionState::RouteRebuilding); }
|
|| (m_routingSessionState == routing::SessionState::RouteRebuilding); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether we are currently routing.
|
||||||
|
*/
|
||||||
|
bool IsRouting() const { return m_routingSessionState != routing::SessionState::NoValidRoute; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether the traffic manager is paused and not routing.
|
||||||
|
*
|
||||||
|
* This is used to inhibit polling and message decoding.
|
||||||
|
*/
|
||||||
|
bool IsPausedAndNotRouting() const { return m_isPaused && !IsRouting(); }
|
||||||
|
|
||||||
DataSource & m_dataSource;
|
DataSource & m_dataSource;
|
||||||
CountryInfoGetterFn m_countryInfoGetterFn;
|
CountryInfoGetterFn m_countryInfoGetterFn;
|
||||||
CountryParentNameGetterFn m_countryParentNameGetterFn;
|
CountryParentNameGetterFn m_countryParentNameGetterFn;
|
||||||
|
|||||||
Reference in New Issue
Block a user