diff options
author | vng <viktor.govako@gmail.com> | 2012-10-18 20:37:22 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:45:48 +0300 |
commit | a22b951b8d5b6ee5376635ee0c1a2889af2390e4 (patch) | |
tree | 21ed3a4204261c183af161d33e4877d7f099ed52 /search | |
parent | 54bb28b0d93b268ef52fa8745ad23b4b3b2da5f7 (diff) |
Revert mutex lock for reading search params. Engine::Search is calling from main thread always.
Diffstat (limited to 'search')
-rw-r--r-- | search/search_engine.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/search/search_engine.cpp b/search/search_engine.cpp index d8b149822e..4f7b150382 100644 --- a/search/search_engine.cpp +++ b/search/search_engine.cpp @@ -142,25 +142,28 @@ void Engine::PrepareSearch(m2::RectD const & viewport, bool Engine::Search(SearchParams const & params, m2::RectD const & viewport) { - { - threads::MutexGuard guard(m_updateMutex); + // Check for equal query. + // There is no need to put synch here for reading m_params, + // because this function is always called from main thread (one-by-one for queries). - // Check for equal query. - if (!params.IsResetMode() && - m_params.IsEqualCommon(params) && - m2::IsEqual(m_viewport, viewport, epsEqualRects, epsEqualRects)) - { - if (!m_params.m_validPos) - return false; + if (!params.IsResetMode() && + m_params.IsEqualCommon(params) && + m2::IsEqual(m_viewport, viewport, epsEqualRects, epsEqualRects)) + { + if (!m_params.m_validPos) + return false; - m2::PointD const p1 = GetViewportXY(m_params.m_lat, m_params.m_lon); - m2::PointD const p2 = GetViewportXY(params.m_lat, params.m_lon); + m2::PointD const p1 = GetViewportXY(m_params.m_lat, m_params.m_lon); + m2::PointD const p2 = GetViewportXY(params.m_lat, params.m_lon); - if (p1.EqualDxDy(p2, epsEqualPoints)) - return false; - } + if (p1.EqualDxDy(p2, epsEqualPoints)) + return false; + } + { // Assign new search params. + // Put the synch here, because this params are reading in search threads. + threads::MutexGuard guard(m_updateMutex); m_params = params; m_viewport = viewport; } |