aboutsummaryrefslogtreecommitdiff
path: root/launcher/tasks
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-07-24 16:19:25 -0300
committerflow <flowlnlnln@gmail.com>2022-07-24 17:46:54 -0300
commita9e8ed5087fb559352d3ef14b575718181ffaa32 (patch)
tree22e344419d12170d31df19a502ac9119f0c51ad5 /launcher/tasks
parent00520b6a0e0ca3987cd4f7eef6e712c61fbb89f8 (diff)
downloadPrismLauncher-a9e8ed5087fb559352d3ef14b575718181ffaa32.tar.gz
PrismLauncher-a9e8ed5087fb559352d3ef14b575718181ffaa32.tar.bz2
PrismLauncher-a9e8ed5087fb559352d3ef14b575718181ffaa32.zip
fix: pump events and do a queued start for concurrent tasks
Heavy workloads can consume a ton of time doing their stuff, and starve the event loop out of events. This adds an event processing call after every concurrent task has been completed, to decrease the event loop stravation on such loads. Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/tasks')
-rw-r--r--launcher/tasks/ConcurrentTask.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index b88cfb13..ab7cbd03 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -1,10 +1,11 @@
#include "ConcurrentTask.h"
#include <QDebug>
+#include <QCoreApplication>
ConcurrentTask::ConcurrentTask(QObject* parent, QString task_name, int max_concurrent)
: Task(parent), m_name(task_name), m_total_max_size(max_concurrent)
-{}
+{ setObjectName(task_name); }
ConcurrentTask::~ConcurrentTask()
{
@@ -36,8 +37,9 @@ void ConcurrentTask::executeTask()
{
m_total_size = m_queue.size();
- for (int i = 0; i < m_total_max_size; i++)
- startNext();
+ for (int i = 0; i < m_total_max_size; i++) {
+ QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
+ }
}
bool ConcurrentTask::abort()
@@ -91,6 +93,8 @@ void ConcurrentTask::startNext()
setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus());
updateState();
+ QCoreApplication::processEvents();
+
next->start();
}