forked from qt-creator/qt-creator
TaskTree: Fix continuation of group with parallel limit
Change-Id: I10c40d06c21a0446187b8227b526ee903c569307 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -147,7 +147,7 @@ public:
|
|||||||
const TaskItem &task);
|
const TaskItem &task);
|
||||||
~TaskContainer();
|
~TaskContainer();
|
||||||
TaskAction start();
|
TaskAction start();
|
||||||
TaskAction startChildren();
|
TaskAction startChildren(int nextChild);
|
||||||
void stop();
|
void stop();
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
int taskCount() const;
|
int taskCount() const;
|
||||||
@@ -370,13 +370,13 @@ TaskAction TaskContainer::start()
|
|||||||
resetSuccessBit();
|
resetSuccessBit();
|
||||||
|
|
||||||
GuardLocker locker(m_startGuard);
|
GuardLocker locker(m_startGuard);
|
||||||
return startChildren();
|
return startChildren(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskAction TaskContainer::startChildren()
|
TaskAction TaskContainer::startChildren(int nextChild)
|
||||||
{
|
{
|
||||||
const int childCount = m_children.size();
|
const int childCount = m_children.size();
|
||||||
for (int i = m_doneCount; i < childCount; ++i) {
|
for (int i = nextChild; i < childCount; ++i) {
|
||||||
const int limit = currentLimit();
|
const int limit = currentLimit();
|
||||||
if (i >= limit)
|
if (i >= limit)
|
||||||
break;
|
break;
|
||||||
@@ -432,7 +432,7 @@ int TaskContainer::taskCount() const
|
|||||||
int TaskContainer::currentLimit() const
|
int TaskContainer::currentLimit() const
|
||||||
{
|
{
|
||||||
const int childCount = m_children.size();
|
const int childCount = m_children.size();
|
||||||
return m_parallelLimit ? qMin(m_doneCount + m_parallelLimit, childCount) : childCount;
|
return m_parallelLimit ? qMin(m_doneCount + m_parallelLimit, childCount) : childCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskAction TaskContainer::childDone(bool success)
|
TaskAction TaskContainer::childDone(bool success)
|
||||||
@@ -445,6 +445,7 @@ TaskAction TaskContainer::childDone(bool success)
|
|||||||
return toTaskAction(success);
|
return toTaskAction(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int limit = currentLimit();
|
||||||
++m_doneCount;
|
++m_doneCount;
|
||||||
updateSuccessBit(success);
|
updateSuccessBit(success);
|
||||||
|
|
||||||
@@ -460,7 +461,10 @@ TaskAction TaskContainer::childDone(bool success)
|
|||||||
if (m_startGuard.isLocked())
|
if (m_startGuard.isLocked())
|
||||||
return TaskAction::Continue;
|
return TaskAction::Continue;
|
||||||
|
|
||||||
return startChildren();
|
if (limit >= m_children.size())
|
||||||
|
return TaskAction::Continue;
|
||||||
|
|
||||||
|
return startChildren(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskContainer::groupDone(bool success)
|
void TaskContainer::groupDone(bool success)
|
||||||
@@ -563,6 +567,7 @@ void TaskContainer::deactivateStorages()
|
|||||||
|
|
||||||
TaskAction TaskNode::start()
|
TaskAction TaskNode::start()
|
||||||
{
|
{
|
||||||
|
QTC_CHECK(!isRunning());
|
||||||
if (!isTask())
|
if (!isTask())
|
||||||
return m_container.start();
|
return m_container.start();
|
||||||
|
|
||||||
|
@@ -565,6 +565,53 @@ void tst_TaskTree::processTree_data()
|
|||||||
{-1, Handler::GroupDone}};
|
{-1, Handler::GroupDone}};
|
||||||
QTest::newRow("DynamicSetupContinue") << dynamicSetupContinueRoot << storage
|
QTest::newRow("DynamicSetupContinue") << dynamicSetupContinueRoot << storage
|
||||||
<< dynamicSetupContinueLog << true << true << 4;
|
<< dynamicSetupContinueLog << true << true << 4;
|
||||||
|
|
||||||
|
const Group nestedParallelRoot {
|
||||||
|
ParallelLimit(2),
|
||||||
|
Storage(storage),
|
||||||
|
Group {
|
||||||
|
Storage(TreeStorage<CustomStorage>()),
|
||||||
|
OnGroupSetup(std::bind(groupSetup, 1)),
|
||||||
|
Group {
|
||||||
|
parallel,
|
||||||
|
Process(std::bind(setupProcess, _1, 1)),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
Storage(TreeStorage<CustomStorage>()),
|
||||||
|
OnGroupSetup(std::bind(groupSetup, 2)),
|
||||||
|
Group {
|
||||||
|
parallel,
|
||||||
|
Process(std::bind(setupProcess, _1, 2)),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
Storage(TreeStorage<CustomStorage>()),
|
||||||
|
OnGroupSetup(std::bind(groupSetup, 3)),
|
||||||
|
Group {
|
||||||
|
parallel,
|
||||||
|
Process(std::bind(setupProcess, _1, 3)),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
Storage(TreeStorage<CustomStorage>()),
|
||||||
|
OnGroupSetup(std::bind(groupSetup, 4)),
|
||||||
|
Group {
|
||||||
|
parallel,
|
||||||
|
Process(std::bind(setupProcess, _1, 4)),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const Log nestedParallelLog{{1, Handler::GroupSetup},
|
||||||
|
{1, Handler::Setup},
|
||||||
|
{2, Handler::GroupSetup},
|
||||||
|
{2, Handler::Setup},
|
||||||
|
{3, Handler::GroupSetup},
|
||||||
|
{3, Handler::Setup},
|
||||||
|
{4, Handler::GroupSetup},
|
||||||
|
{4, Handler::Setup}};
|
||||||
|
QTest::newRow("NestedParallel") << nestedParallelRoot << storage << nestedParallelLog
|
||||||
|
<< true << true << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_TaskTree::processTree()
|
void tst_TaskTree::processTree()
|
||||||
|
Reference in New Issue
Block a user