diff options
Diffstat (limited to 'tests/dummyresourcebenchmark.cpp')
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index 72562c3..8636bf6 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -44,34 +44,6 @@ private slots: | |||
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | static KAsync::Job<void> waitForCompletion(QList<KAsync::Future<void>> &futures) | ||
48 | { | ||
49 | auto context = new QObject; | ||
50 | return KAsync::start<void>([futures, context](KAsync::Future<void> &future) { | ||
51 | const auto total = futures.size(); | ||
52 | auto count = QSharedPointer<int>::create(); | ||
53 | int i = 0; | ||
54 | for (KAsync::Future<void> subFuture : futures) { | ||
55 | i++; | ||
56 | if (subFuture.isFinished()) { | ||
57 | *count += 1; | ||
58 | continue; | ||
59 | } | ||
60 | // FIXME bind lifetime all watcher to future (repectively the main job | ||
61 | auto watcher = QSharedPointer<KAsync::FutureWatcher<void>>::create(); | ||
62 | QObject::connect(watcher.data(), &KAsync::FutureWatcher<void>::futureReady, [count, total, &future]() { | ||
63 | *count += 1; | ||
64 | if (*count == total) { | ||
65 | future.setFinished(); | ||
66 | } | ||
67 | }); | ||
68 | watcher->setFuture(subFuture); | ||
69 | context->setProperty(QString("future%1").arg(i).toLatin1().data(), QVariant::fromValue(watcher)); | ||
70 | } | ||
71 | }) | ||
72 | .then<void>([context]() { delete context; }); | ||
73 | } | ||
74 | |||
75 | // Ensure we can process a command in less than 0.1s | 47 | // Ensure we can process a command in less than 0.1s |
76 | void testCommandResponsiveness() | 48 | void testCommandResponsiveness() |
77 | { | 49 | { |
@@ -120,7 +92,7 @@ private slots: | |||
120 | event.setProperty("summary", "summaryValue"); | 92 | event.setProperty("summary", "summaryValue"); |
121 | waitCondition << Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec(); | 93 | waitCondition << Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec(); |
122 | } | 94 | } |
123 | waitForCompletion(waitCondition).exec().waitForFinished(); | 95 | KAsync::waitForCompletion(waitCondition).exec().waitForFinished(); |
124 | auto appendTime = time.elapsed(); | 96 | auto appendTime = time.elapsed(); |
125 | 97 | ||
126 | // Ensure everything is processed | 98 | // Ensure everything is processed |