iOS thread reuse bugfix in routing

This commit is contained in:
Lev Dragunov 2015-07-08 17:21:06 +03:00 committed by Alex Zolotarev
parent edf1bc457d
commit f3230fb86e
2 changed files with 7 additions and 5 deletions

View file

@ -22,16 +22,18 @@ void OnlineAbsentCountriesFetcher::GenerateRequest(const m2::PointD & startPoint
unique_ptr<OnlineCrossFetcher> fetcher =
make_unique<OnlineCrossFetcher>(OSRM_ONLINE_SERVER_URL, MercatorBounds::ToLatLon(startPoint),
MercatorBounds::ToLatLon(finalPoint));
m_fetcherThread.Create(move(fetcher));
// iOS can't reuse threads. So we need to recreate the thread.
m_fetcherThread.reset(new threads::Thread());
m_fetcherThread->Create(move(fetcher));
}
void OnlineAbsentCountriesFetcher::GetAbsentCountries(vector<string> & countries)
{
// Check whether a request was scheduled to be run on the thread.
if (!m_fetcherThread.GetRoutine())
if (!m_fetcherThread->GetRoutine())
return;
m_fetcherThread.Join();
for (auto const & point : m_fetcherThread.GetRoutineAs<OnlineCrossFetcher>()->GetMwmPoints())
m_fetcherThread->Join();
for (auto const & point : m_fetcherThread->GetRoutineAs<OnlineCrossFetcher>()->GetMwmPoints())
{
string name = m_countryFileFn(point);
auto localFile = m_countryLocalFileFn(name);

View file

@ -27,6 +27,6 @@ public:
private:
TCountryFileFn const m_countryFileFn;
TCountryLocalFileFn const m_countryLocalFileFn;
threads::Thread m_fetcherThread;
unique_ptr<threads::Thread> m_fetcherThread;
};
} // namespace routing