TaskTree: Introduce timeoutTask helper

By default it finishes with error.

Change-Id: Idff895f02736818762127e248f6ee8217cc2c809
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-16 11:19:00 +01:00
parent fdd15ca9af
commit 49a0cd2eed
4 changed files with 11 additions and 5 deletions

View File

@@ -3635,6 +3635,11 @@ void TimeoutTaskAdapter::start()
}); });
} }
ExecutableItem timeoutTask(const std::chrono::milliseconds &timeout, DoneResult result)
{
return TimeoutTask([timeout](std::chrono::milliseconds &t) { t = timeout; }, result);
}
/*! /*!
\typealias Tasking::TaskTreeTask \typealias Tasking::TaskTreeTask

View File

@@ -707,6 +707,9 @@ private:
using TaskTreeTask = CustomTask<TaskTreeTaskAdapter>; using TaskTreeTask = CustomTask<TaskTreeTaskAdapter>;
using TimeoutTask = CustomTask<TimeoutTaskAdapter>; using TimeoutTask = CustomTask<TimeoutTaskAdapter>;
TASKING_EXPORT ExecutableItem timeoutTask(const std::chrono::milliseconds &timeout,
DoneResult result = DoneResult::Error);
} // namespace Tasking } // namespace Tasking
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@@ -5,7 +5,6 @@
#include "androidconfigurations.h" #include "androidconfigurations.h"
#include "androidconstants.h" #include "androidconstants.h"
#include "androiddeviceinfo.h"
#include "androidtr.h" #include "androidtr.h"
#include "androidutils.h" #include "androidutils.h"
@@ -874,8 +873,7 @@ static ExecutableItem pidRecipe(const Storage<RunnerStorage> &storage)
Forever { Forever {
stopOnSuccess, stopOnSuccess,
ProcessTask(onPidSetup, onPidDone, CallDoneIf::Success), ProcessTask(onPidSetup, onPidDone, CallDoneIf::Success),
TimeoutTask([](std::chrono::milliseconds &timeout) { timeout = 200ms; }, timeoutTask(200ms)
DoneResult::Error)
}.withTimeout(45s), }.withTimeout(45s),
ProcessTask(onUserSetup, onUserDone, CallDoneIf::Success), ProcessTask(onUserSetup, onUserDone, CallDoneIf::Success),
ProcessTask(onArtSetup, onArtDone), ProcessTask(onArtSetup, onArtDone),

View File

@@ -736,13 +736,13 @@ static ExecutableItem waitForAvdRecipe(const QString &avdName, const Storage<QSt
Forever { Forever {
stopOnSuccess, stopOnSuccess,
serialNumberRecipe(avdName, serialNumberStorage), serialNumberRecipe(avdName, serialNumberStorage),
TimeoutTask([](std::chrono::milliseconds &timeout) { timeout = 100ms; }, DoneResult::Error) timeoutTask(100ms)
}.withTimeout(30s), }.withTimeout(30s),
Forever { Forever {
stopStorage, stopStorage,
stopOnSuccess, stopOnSuccess,
isAvdBootedRecipe(serialNumberStorage), isAvdBootedRecipe(serialNumberStorage),
TimeoutTask([](std::chrono::milliseconds &timeout) { timeout = 100ms; }, DoneResult::Error), timeoutTask(100ms),
Group { Group {
outputStorage, outputStorage,
AndroidConfig::devicesCommandOutputRecipe(outputStorage), AndroidConfig::devicesCommandOutputRecipe(outputStorage),