forked from qt-creator/qt-creator
TaskTree manual test: Use QPromise for async calls
Change-Id: I532520af644b431441d74c0e06eff4d06d0b3924 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -18,11 +18,11 @@
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
// TODO: make tasks cancellable
|
// TODO: make tasks cancellable
|
||||||
static void sleepInThread(QFutureInterface<void> &fi, int seconds, bool reportSuccess)
|
static void sleepInThread(QPromise<void> &promise, int seconds, bool reportSuccess)
|
||||||
{
|
{
|
||||||
QThread::sleep(seconds);
|
QThread::sleep(seconds);
|
||||||
if (!reportSuccess)
|
if (!reportSuccess)
|
||||||
fi.reportCanceled();
|
promise.future().cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
auto taskItem = [sync = &synchronizer, synchronizerCheckBox](TaskWidget *widget) {
|
auto taskItem = [sync = &synchronizer, synchronizerCheckBox](TaskWidget *widget) {
|
||||||
const auto setupHandler = [=](AsyncTask<void> &task) {
|
const auto setupHandler = [=](AsyncTask<void> &task) {
|
||||||
task.setAsyncCallData(sleepInThread, widget->busyTime(), widget->isSuccess());
|
task.setConcurrentCallData(sleepInThread, widget->busyTime(), widget->isSuccess());
|
||||||
if (synchronizerCheckBox->isChecked())
|
if (synchronizerCheckBox->isChecked())
|
||||||
task.setFutureSynchronizer(sync);
|
task.setFutureSynchronizer(sync);
|
||||||
widget->setState(State::Running);
|
widget->setState(State::Running);
|
||||||
|
Reference in New Issue
Block a user