From 45610d1dcf47239551d4d3051719c9abb12ef10d Mon Sep 17 00:00:00 2001 From: Sergey Yershov Date: Mon, 27 Jul 2015 16:25:24 +0300 Subject: [PATCH] Code fix --- generator/coastlines_generator.cpp | 25 +++++++------------------ generator/coastlines_generator.hpp | 4 +--- generator/osm_source.cpp | 6 ++---- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/generator/coastlines_generator.cpp b/generator/coastlines_generator.cpp index b6b0be815a..8f20bc1608 100644 --- a/generator/coastlines_generator.cpp +++ b/generator/coastlines_generator.cpp @@ -22,12 +22,9 @@ typedef m2::RectI RectT; DECLARE_bool(fail_on_coasts); -CoastlineFeaturesGenerator::CoastlineFeaturesGenerator(uint32_t coastType, - int lowLevel, int highLevel, int maxPoints) - : m_merger(POINT_COORD_BITS), m_coastType(coastType), - m_lowLevel(lowLevel), m_highLevel(highLevel), m_maxPoints(maxPoints) +CoastlineFeaturesGenerator::CoastlineFeaturesGenerator(uint32_t coastType) + : m_merger(POINT_COORD_BITS), m_coastType(coastType) { - ASSERT_LESS_OR_EQUAL ( m_lowLevel, m_highLevel, () ); } namespace @@ -221,11 +218,12 @@ public: typedef m4::Tree TIndex; typedef function TProcessResultFunc; + enum {kHighLevel = 10, kMaxPoints = 20000}; + protected: TIndex const & m_index; mutex & m_mutexTasks; list & m_listTasks; - list m_errorCell; condition_variable & m_listCondVar; size_t & m_inWork; TProcessResultFunc m_processResultFunc; @@ -288,7 +286,7 @@ public: m_index.ForEachInRect(GetLimitRect(rectR), bind(ref(doDiff), _1)); // Check if too many points for feature. - if (cell.Level() < 10 /*m_highLevel*/ && doDiff.GetPointsCount() >= 20000 /*m_maxPoints*/) + if (cell.Level() < kHighLevel && doDiff.GetPointsCount() >= kMaxPoints) return false; { @@ -297,7 +295,6 @@ public: m_processResultFunc(cell, doDiff); } - return true; } @@ -307,13 +304,12 @@ public: // thread main loop for (;;) { - TCell currentCell; unique_lock lock(m_mutexTasks); m_listCondVar.wait(lock, [this]{return (!m_listTasks.empty() || m_inWork == 0);}); if (m_listTasks.empty() && m_inWork == 0) break; - currentCell = m_listTasks.front(); + TCell currentCell = m_listTasks.front(); m_listTasks.pop_front(); ++m_inWork; lock.unlock(); @@ -330,13 +326,6 @@ public: --m_inWork; m_listCondVar.notify_all(); } - - // return back cells with error into task queue - if (!m_errorCell.empty()) - { - unique_lock lock(m_mutexTasks); - m_listTasks.insert(m_listTasks.end(), m_errorCell.begin(), m_errorCell.end()); - } } }; @@ -349,7 +338,7 @@ void CoastlineFeaturesGenerator::GetFeatures(size_t baseLevel, vector vecFb; - m_coasts->GetFeatures(4 /*m_lowLevel*/, vecFb); + m_coasts->GetFeatures(4 /*start level*/, vecFb); for (size_t j = 0; j < vecFb.size(); ++j) {