mirror of
https://github.com/tnodir/fort
synced 2024-11-15 05:36:09 +00:00
UI: WorkerManager: Wait workers finishing.
This commit is contained in:
parent
baffe6aba5
commit
b89e685212
@ -40,6 +40,10 @@ void WorkerManager::workerFinished(WorkerObject *worker)
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
m_workers.removeOne(worker);
|
||||
|
||||
if (m_workers.isEmpty()) {
|
||||
m_waitCondition.wakeOne();
|
||||
}
|
||||
}
|
||||
|
||||
void WorkerManager::clear()
|
||||
@ -53,20 +57,19 @@ void WorkerManager::abort()
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
abortWorkers();
|
||||
|
||||
m_aborted = true;
|
||||
|
||||
m_waitCondition.wakeAll();
|
||||
}
|
||||
if (!m_workers.isEmpty()) {
|
||||
for (WorkerObject *worker : m_workers) {
|
||||
worker->abort();
|
||||
}
|
||||
|
||||
void WorkerManager::abortWorkers()
|
||||
{
|
||||
for (WorkerObject *worker : m_workers) {
|
||||
worker->abort();
|
||||
m_waitCondition.wakeAll();
|
||||
|
||||
do {
|
||||
m_waitCondition.wait(&m_mutex);
|
||||
} while (!m_workers.isEmpty());
|
||||
}
|
||||
|
||||
m_workers.clear();
|
||||
}
|
||||
|
||||
void WorkerManager::enqueueJob(const QString &job)
|
||||
|
@ -41,7 +41,6 @@ private:
|
||||
void setupWorker();
|
||||
|
||||
void abort();
|
||||
void abortWorkers();
|
||||
|
||||
private:
|
||||
volatile bool m_aborted;
|
||||
|
@ -19,7 +19,5 @@ void WorkerObject::run()
|
||||
doJob(job);
|
||||
}
|
||||
|
||||
if (!aborted()) {
|
||||
manager()->workerFinished(this);
|
||||
}
|
||||
manager()->workerFinished(this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user