feat(Tasks): allow adding subtasks while running in ConcurrentTask
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
		| @@ -27,10 +27,8 @@ auto ConcurrentTask::getStepTotalProgress() const -> qint64 | ||||
|  | ||||
| void ConcurrentTask::addTask(Task::Ptr task) | ||||
| { | ||||
|     if (!isRunning()) | ||||
|         m_queue.append(task); | ||||
|     else | ||||
|         qWarning() << "Tried to add a task to a running concurrent task!"; | ||||
|     m_queue.append(task); | ||||
|     m_total_size += 1; | ||||
| } | ||||
|  | ||||
| void ConcurrentTask::executeTask() | ||||
| @@ -117,9 +115,14 @@ void ConcurrentTask::startNext() | ||||
|     setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus()); | ||||
|     updateState(); | ||||
|  | ||||
|     QCoreApplication::processEvents(); | ||||
|     QMetaObject::invokeMethod(next.get(), &Task::start, Qt::QueuedConnection); | ||||
|  | ||||
|     next->start(); | ||||
|     // Allow going up the number of concurrent tasks in case of tasks being added in the middle of a running task. | ||||
|     int num_starts = m_total_max_size - m_doing.size(); | ||||
|     for (int i = 0; i < num_starts; i++) | ||||
|         QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection); | ||||
|  | ||||
|     QCoreApplication::processEvents(); | ||||
| } | ||||
|  | ||||
| void ConcurrentTask::subTaskSucceeded(Task::Ptr task) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 flow
					flow