summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-02-27 21:36:45 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-03-13 23:26:28 +0200
commit0d29a406f724fcc63e06530e4cf189fd3ca679f6 (patch)
tree1c01510d80e6d6f1d7032e3291b2c974642182a3 /tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
parentd7f0677368a96df7c4f381affd52323ebce8f978 (diff)
QThread: add sleep(std::chrono::nanoseconds) overload
All the other overloads are implemented using the new one. Windows change relies on the pre-check in the code review making sure it compiles. [ChangeLog][QtCore][QThread] Added sleep(std::chrono::nanoseconds) overload. Task-number: QTBUG-110059 Change-Id: I9a4f4bf09041788ec9275093b6b8d0386521e286 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/thread/qpromise/tst_qpromise.cpp')
-rw-r--r--tests/auto/corelib/thread/qpromise/tst_qpromise.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
index c63fb74616..6c23884b36 100644
--- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
+++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
@@ -14,6 +14,8 @@
#include <memory>
#include <chrono>
+using namespace std::chrono_literals;
+
class tst_QPromise : public QObject
{
Q_OBJECT
@@ -480,7 +482,7 @@ void tst_QPromise::cancelWhenReassigned()
promise.start();
ThreadWrapper thr([p = std::move(promise)] () mutable {
- QThread::msleep(100);
+ QThread::sleep(100ms);
p = QPromise<int>(); // assign new promise, old must be correctly destroyed
});
@@ -537,7 +539,7 @@ void tst_QPromise::finishWhenSwapped()
promise2.start();
ThreadWrapper thr([&promise1, &promise2] () mutable {
- QThread::msleep(100);
+ QThread::sleep(100ms);
promise1.addResult(0);
promise2.addResult(1);
swap(promise1, promise2); // ADL must resolve this
@@ -580,7 +582,7 @@ void tst_QPromise::cancelWhenMoved()
// Move promises to local scope to test cancellation behavior
ThreadWrapper thr([p1 = std::move(promise1), p2 = std::move(promise2)] () mutable {
- QThread::msleep(100);
+ QThread::sleep(100ms);
p1 = std::move(p2);
p1.finish(); // this finish is for future #2
});
@@ -616,7 +618,7 @@ void tst_QPromise::waitUntilResumed()
while (!f.isSuspended()) { // busy wait until worker thread suspends
QCOMPARE(f.isFinished(), false); // exit condition in case of failure
- QThread::msleep(50); // allow another thread to actually carry on
+ QThread::sleep(50ms); // allow another thread to actually carry on
}
f.resume();
@@ -645,7 +647,7 @@ void tst_QPromise::waitUntilCanceled()
while (!f.isSuspended()) { // busy wait until worker thread suspends
QCOMPARE(f.isFinished(), false); // exit condition in case of failure
- QThread::msleep(50); // allow another thread to actually carry on
+ QThread::sleep(50ms); // allow another thread to actually carry on
}
f.cancel();