From 6fcfae99d3615c7a850e4933691763097078c8e4 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 7 Nov 2011 13:39:35 +0100 Subject: Remove warnings from deprecated atomic operators in autotests Use QAtomic*::load() and ::store() instead of the deprecated cast, assignment, and comparison operators. These will be removed in the near future. The tests for these particular operators have not been changed, though, as the change to remove the operators will also remove the respective tests. Change-Id: I2f24d18992af0c6e0f487d707218e4e84f4bdd12 Reviewed-by: Friedemann Kleint --- .../tst_qtconcurrentiteratekernel.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/auto/corelib/concurrent/qtconcurrentiteratekernel') diff --git a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index 4af71d58fd..ed714101e7 100644 --- a/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/corelib/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -106,7 +106,7 @@ QAtomicInt iterations; class PrintFor : public IterateKernel { public: - PrintFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) {iterations = 0; } + PrintFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) { iterations.store(0); } bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { iterations.fetchAndAddRelaxed(end - begin); @@ -125,7 +125,7 @@ public: class SleepPrintFor : public IterateKernel { public: - SleepPrintFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) {iterations = 0; } + SleepPrintFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) { iterations.store(0); } inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { QTest::qSleep(200); @@ -145,7 +145,7 @@ public: void tst_QtConcurrentIterateKernel::instantiate() { startThreadEngine(new PrintFor(0, 40)).startBlocking(); - QCOMPARE((int)iterations, 40); + QCOMPARE(iterations.load(), 40); } void tst_QtConcurrentIterateKernel::cancel() @@ -155,7 +155,7 @@ void tst_QtConcurrentIterateKernel::cancel() f.cancel(); f.waitForFinished(); QVERIFY(f.isCanceled()); - QVERIFY(int(iterations) <= QThread::idealThreadCount()); // the threads might run one iteration each before they are canceled. + QVERIFY(iterations.load() <= QThread::idealThreadCount()); // the threads might run one iteration each before they are canceled. } } @@ -163,7 +163,7 @@ QAtomicInt counter; class CountFor : public IterateKernel { public: - CountFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) {iterations = 0; } + CountFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) { iterations.store(0); } inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { counter.fetchAndAddRelaxed(end - begin); @@ -180,10 +180,10 @@ void tst_QtConcurrentIterateKernel::stresstest() const int iterations = 1000; const int times = 50; for (int i = 0; i < times; ++i) { - counter = 0; + counter.store(0); CountFor f(0, iterations); f.startBlocking(); - QCOMPARE((int)counter, iterations); + QCOMPARE(counter.load(), iterations); } } @@ -202,7 +202,7 @@ public: // this class throttles between iterations 100 and 200, // and then records how many threads that run between // iterations 140 and 160. - ThrottleFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) {iterations = 0; throttling = false; } + ThrottleFor(TestIterator begin, TestIterator end) : IterateKernel(begin, end) { iterations.store(0); throttling = false; } inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { if (200 >= begin && 200 < end) { @@ -241,14 +241,14 @@ public: void tst_QtConcurrentIterateKernel::throttling() { const int totalIterations = 400; - iterations = 0; + iterations.store(0); threads.clear(); ThrottleFor f(0, totalIterations); f.startBlocking(); - QCOMPARE((int)iterations, totalIterations); + QCOMPARE(iterations.load(), totalIterations); QCOMPARE(threads.count(), 1); -- cgit v1.2.3