mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:15:39 +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);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
m_workers.removeOne(worker);
|
m_workers.removeOne(worker);
|
||||||
|
|
||||||
|
if (m_workers.isEmpty()) {
|
||||||
|
m_waitCondition.wakeOne();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerManager::clear()
|
void WorkerManager::clear()
|
||||||
@ -53,20 +57,19 @@ void WorkerManager::abort()
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
abortWorkers();
|
|
||||||
|
|
||||||
m_aborted = true;
|
m_aborted = true;
|
||||||
|
|
||||||
m_waitCondition.wakeAll();
|
if (!m_workers.isEmpty()) {
|
||||||
}
|
for (WorkerObject *worker : m_workers) {
|
||||||
|
worker->abort();
|
||||||
|
}
|
||||||
|
|
||||||
void WorkerManager::abortWorkers()
|
m_waitCondition.wakeAll();
|
||||||
{
|
|
||||||
for (WorkerObject *worker : m_workers) {
|
do {
|
||||||
worker->abort();
|
m_waitCondition.wait(&m_mutex);
|
||||||
|
} while (!m_workers.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_workers.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkerManager::enqueueJob(const QString &job)
|
void WorkerManager::enqueueJob(const QString &job)
|
||||||
|
@ -41,7 +41,6 @@ private:
|
|||||||
void setupWorker();
|
void setupWorker();
|
||||||
|
|
||||||
void abort();
|
void abort();
|
||||||
void abortWorkers();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
volatile bool m_aborted;
|
volatile bool m_aborted;
|
||||||
|
@ -19,7 +19,5 @@ void WorkerObject::run()
|
|||||||
doJob(job);
|
doJob(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aborted()) {
|
manager()->workerFinished(this);
|
||||||
manager()->workerFinished(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user