Simplify the stop process of thumbnail generators

This commit is contained in:
David Capello 2019-03-26 10:59:11 -03:00
parent ce27188852
commit 8ba0ea4519
2 changed files with 9 additions and 17 deletions

View File

@ -55,6 +55,12 @@ public:
m_thread.join();
}
void stop() const {
base::scoped_lock lock(m_mutex);
if (m_fop)
m_fop->stop();
}
bool isDone() const {
return m_isDone;
}
@ -285,21 +291,9 @@ void ThumbnailGenerator::stopAllWorkers()
}
}
base::thread* ptr = new base::thread(base::Bind<void>(&ThumbnailGenerator::stopAllWorkersBackground, this));
m_stopThread.reset(ptr);
}
void ThumbnailGenerator::stopAllWorkersBackground()
{
WorkerList workersCopy;
{
base::scoped_lock hold(m_workersAccess);
workersCopy = m_workers;
m_workers.clear();
}
for (auto worker : workersCopy)
delete worker;
base::scoped_lock hold(m_workersAccess);
for (auto worker : m_workers)
worker->stop();
}
} // namespace app

View File

@ -43,8 +43,6 @@ namespace app {
void stopAllWorkers();
private:
void stopAllWorkersBackground();
class Worker;
typedef std::vector<Worker*> WorkerList;