diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-01-25 14:26:34 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-01-31 16:10:01 +0000 |
commit | 966f4ea6a9d1e46833fc30df878ba6fa8f919988 (patch) | |
tree | 7f37c2adcf4dd6fe002585fb3b3c2815b21c5f26 /src/plugins/android/androidavdmanager.cpp | |
parent | 536618b012b44b5ced428fc39600931803d5dd44 (diff) |
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/android/androidavdmanager.cpp')
-rw-r--r-- | src/plugins/android/androidavdmanager.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/plugins/android/androidavdmanager.cpp b/src/plugins/android/androidavdmanager.cpp index 73a0c961b9c..1d9f639588f 100644 --- a/src/plugins/android/androidavdmanager.cpp +++ b/src/plugins/android/androidavdmanager.cpp @@ -327,17 +327,18 @@ QString AndroidAvdManager::findAvd(const QString &avdName) const return QString(); } -QString AndroidAvdManager::waitForAvd(const QString &avdName, const QFutureInterface<bool> &fi) const +QString AndroidAvdManager::waitForAvd(const QString &avdName, + const std::function<bool()> &cancelChecker) const { // we cannot use adb -e wait-for-device, since that doesn't work if a emulator is already running // 60 rounds of 2s sleeping, two minutes for the avd to start QString serialNumber; for (int i = 0; i < 60; ++i) { - if (fi.isCanceled()) + if (cancelChecker()) return QString(); serialNumber = findAvd(avdName); if (!serialNumber.isEmpty()) - return waitForBooted(serialNumber, fi) ? serialNumber : QString(); + return waitForBooted(serialNumber, cancelChecker) ? serialNumber : QString(); QThread::sleep(2); } return QString(); @@ -358,11 +359,12 @@ bool AndroidAvdManager::isAvdBooted(const QString &device) const return value == "stopped"; } -bool AndroidAvdManager::waitForBooted(const QString &serialNumber, const QFutureInterface<bool> &fi) const +bool AndroidAvdManager::waitForBooted(const QString &serialNumber, + const std::function<bool()> &cancelChecker) const { // found a serial number, now wait until it's done booting... for (int i = 0; i < 60; ++i) { - if (fi.isCanceled()) + if (cancelChecker()) return false; if (isAvdBooted(serialNumber)) { return true; |