From 80e321c9c0b5f7f778d945344be89b2111799b20 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Wed, 23 Sep 2015 16:36:35 +0300 Subject: [PATCH] Release mwm locks when we cancell routing. --- routing/async_router.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/routing/async_router.cpp b/routing/async_router.cpp index 1db36e526b..a6d045788d 100644 --- a/routing/async_router.cpp +++ b/routing/async_router.cpp @@ -170,6 +170,7 @@ void AsyncRouter::ClearState() unique_lock ul(m_guard); m_clearState = true; + m_threadCondVar.notify_one(); ResetDelegate(); } @@ -233,10 +234,19 @@ void AsyncRouter::ThreadFunc() { { unique_lock ul(m_guard); - m_threadCondVar.wait(ul, [this](){ return m_threadExit || m_hasRequest; }); + m_threadCondVar.wait(ul, [this](){ return m_threadExit || m_hasRequest || m_clearState; }); + + if (m_clearState && m_router) + { + m_router->ClearState(); + m_clearState = false; + } if (m_threadExit) break; + + if (!m_hasRequest) + continue; } CalculateRoute(); @@ -245,7 +255,6 @@ void AsyncRouter::ThreadFunc() void AsyncRouter::CalculateRoute() { - bool clearState = true; shared_ptr delegate; m2::PointD startPoint, finalPoint, startDirection; shared_ptr absentFetcher; @@ -266,12 +275,9 @@ void AsyncRouter::CalculateRoute() startPoint = m_startPoint; finalPoint = m_finalPoint; startDirection = m_startDirection; - clearState = m_clearState; delegate = m_delegate; router = m_router; absentFetcher = m_absentFetcher; - - m_clearState = false; } Route route(router->GetName()); @@ -287,9 +293,6 @@ void AsyncRouter::CalculateRoute() if (absentFetcher) absentFetcher->GenerateRequest(startPoint, finalPoint); - if (clearState) - router->ClearState(); - // Run basic request. code = router->CalculateRoute(startPoint, startDirection, finalPoint, delegate->GetDelegate(), route);