Stopped metaline processing in background

This commit is contained in:
r.kuznetsov 2017-06-27 14:40:32 +03:00 committed by Daria Volvenkova
parent ab184a3bff
commit 334d30f1ba
4 changed files with 29 additions and 4 deletions

View file

@ -490,6 +490,7 @@ void BackendRenderer::OnContextCreate()
GLFunctions::Init(m_apiVersion);
m_readManager->Start();
m_metalineManager->Start();
InitGLDependentResource();
}
@ -498,6 +499,7 @@ void BackendRenderer::OnContextDestroy()
LOG(LINFO, ("On context destroy."));
m_readManager->Stop();
m_batchersPool.reset();
m_metalineManager->Stop();
m_texMng->Release();
m_overlays.clear();
m_trafficGenerator->ClearGLDependentResources();

View file

@ -13,14 +13,31 @@ namespace df
MetalineManager::MetalineManager(ref_ptr<ThreadsCommutator> commutator, MapDataProvider & model)
: m_model(model)
, m_tasksPool(4, ReadMetalineTaskFactory(m_model))
, m_threadsPool(make_unique_dp<threads::ThreadPool>(2, std::bind(&MetalineManager::OnTaskFinished,
this, std::placeholders::_1)))
, m_commutator(commutator)
{}
{
Start();
}
MetalineManager::~MetalineManager()
{
m_threadsPool->Stop();
Stop();
}
void MetalineManager::Start()
{
if (m_threadsPool != nullptr)
return;
using namespace std::placeholders;
uint8_t constexpr kThreadsCount = 2;
m_threadsPool = make_unique_dp<threads::ThreadPool>(
kThreadsCount, std::bind(&MetalineManager::OnTaskFinished, this, _1));
}
void MetalineManager::Stop()
{
if (m_threadsPool != nullptr)
m_threadsPool->Stop();
m_threadsPool.reset();
}

View file

@ -20,6 +20,9 @@ public:
MetalineManager(ref_ptr<ThreadsCommutator> commutator, MapDataProvider & model);
~MetalineManager();
void Start();
void Stop();
void Update(std::set<MwmSet::MwmId> const & mwms);
m2::SharedSpline GetMetaline(FeatureID const & fid) const;

View file

@ -108,6 +108,9 @@ void ReadMetalineTask::Do()
auto metalines = ReadMetalinesFromFile(m_mwmId);
for (auto const & metaline : metalines)
{
if (IsCancelled())
return;
bool failed = false;
for (auto const & fid : metaline.m_features)
{