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 <Friedemann.Kleint@nokia.com>bb10
parent
2f90c4e40e
commit
6fcfae99d3
|
|
@ -625,26 +625,26 @@ template <typename T>
|
|||
void testRefCounting()
|
||||
{
|
||||
QFutureInterface<T> interface;
|
||||
QCOMPARE(int(interface.d->refCount), 1);
|
||||
QCOMPARE(interface.d->refCount.load(), 1);
|
||||
|
||||
{
|
||||
interface.reportStarted();
|
||||
|
||||
QFuture<T> f = interface.future();
|
||||
QCOMPARE(int(interface.d->refCount), 2);
|
||||
QCOMPARE(interface.d->refCount.load(), 2);
|
||||
|
||||
QFuture<T> f2(f);
|
||||
QCOMPARE(int(interface.d->refCount), 3);
|
||||
QCOMPARE(interface.d->refCount.load(), 3);
|
||||
|
||||
QFuture<T> f3;
|
||||
f3 = f2;
|
||||
QCOMPARE(int(interface.d->refCount), 4);
|
||||
QCOMPARE(interface.d->refCount.load(), 4);
|
||||
|
||||
interface.reportFinished(0);
|
||||
QCOMPARE(int(interface.d->refCount), 4);
|
||||
QCOMPARE(interface.d->refCount.load(), 4);
|
||||
}
|
||||
|
||||
QCOMPARE(int(interface.d->refCount), 1);
|
||||
QCOMPARE(interface.d->refCount.load(), 1);
|
||||
}
|
||||
|
||||
void tst_QFuture::refcounting()
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ QAtomicInt iterations;
|
|||
class PrintFor : public IterateKernel<TestIterator, void>
|
||||
{
|
||||
public:
|
||||
PrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) {iterations = 0; }
|
||||
PrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(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<TestIterator, void>
|
||||
{
|
||||
public:
|
||||
SleepPrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) {iterations = 0; }
|
||||
SleepPrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(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<TestIterator, void>
|
||||
{
|
||||
public:
|
||||
CountFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) {iterations = 0; }
|
||||
CountFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(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<TestIterator, void>(begin, end) {iterations = 0; throttling = false; }
|
||||
ThrottleFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(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);
|
||||
|
|
|
|||
|
|
@ -2152,8 +2152,8 @@ public:
|
|||
void updatePeak()
|
||||
{
|
||||
forever {
|
||||
const int localPeak = peakInstanceCount;
|
||||
const int localCurrent = currentInstanceCount;
|
||||
const int localPeak = peakInstanceCount.load();
|
||||
const int localCurrent = currentInstanceCount.load();
|
||||
if (localCurrent <= localPeak)
|
||||
break;
|
||||
if (peakInstanceCount.testAndSetOrdered(localPeak, localCurrent))
|
||||
|
|
@ -2191,35 +2191,35 @@ void tst_QtConcurrentMap::throttling()
|
|||
const int allowedTemporaries = QThread::idealThreadCount() * 40;
|
||||
|
||||
{
|
||||
currentInstanceCount = 0;
|
||||
peakInstanceCount = 0;
|
||||
currentInstanceCount.store(0);
|
||||
peakInstanceCount.store(0);
|
||||
|
||||
QList<InstanceCounter> instances;
|
||||
for (int i = 0; i < itemcount; ++i)
|
||||
instances.append(InstanceCounter());
|
||||
|
||||
QCOMPARE((int)currentInstanceCount, itemcount);
|
||||
QCOMPARE(currentInstanceCount.load(), itemcount);
|
||||
|
||||
int results = QtConcurrent::blockingMappedReduced(instances, slowMap, fastReduce);
|
||||
QCOMPARE(results, itemcount);
|
||||
QCOMPARE(int(currentInstanceCount), itemcount);
|
||||
QVERIFY(int(peakInstanceCount) < itemcount + allowedTemporaries);
|
||||
QCOMPARE(currentInstanceCount.load(), itemcount);
|
||||
QVERIFY(peakInstanceCount.load() < itemcount + allowedTemporaries);
|
||||
}
|
||||
|
||||
{
|
||||
QCOMPARE(int(currentInstanceCount), 0);
|
||||
peakInstanceCount = 0;
|
||||
QCOMPARE(currentInstanceCount.load(), 0);
|
||||
peakInstanceCount.store(0);
|
||||
|
||||
QList<InstanceCounter> instances;
|
||||
for (int i = 0; i < itemcount; ++i)
|
||||
instances.append(InstanceCounter());
|
||||
|
||||
QCOMPARE(int(currentInstanceCount), itemcount);
|
||||
QCOMPARE(currentInstanceCount.load(), itemcount);
|
||||
int results = QtConcurrent::blockingMappedReduced(instances, fastMap, slowReduce);
|
||||
|
||||
QCOMPARE(results, itemcount);
|
||||
QCOMPARE((int)currentInstanceCount, itemcount);
|
||||
QVERIFY(int(peakInstanceCount) < itemcount + allowedTemporaries);
|
||||
QCOMPARE(currentInstanceCount.load(), itemcount);
|
||||
QVERIFY(peakInstanceCount.load() < itemcount + allowedTemporaries);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2353,8 +2353,8 @@ InstanceCounter ic_fn(const InstanceCounter & ic)
|
|||
// assigned over with operator ==
|
||||
void tst_QtConcurrentMap::qFutureAssignmentLeak()
|
||||
{
|
||||
currentInstanceCount = 0;
|
||||
peakInstanceCount = 0;
|
||||
currentInstanceCount.store(0);
|
||||
peakInstanceCount.store(0);
|
||||
QFuture<InstanceCounter> future;
|
||||
{
|
||||
QList<InstanceCounter> list;
|
||||
|
|
@ -2370,9 +2370,9 @@ void tst_QtConcurrentMap::qFutureAssignmentLeak()
|
|||
future.waitForFinished();
|
||||
}
|
||||
|
||||
QCOMPARE(int(currentInstanceCount), 1000);
|
||||
QCOMPARE(currentInstanceCount.load(), 1000);
|
||||
future = QFuture<InstanceCounter>();
|
||||
QCOMPARE(int(currentInstanceCount), 0);
|
||||
QCOMPARE(currentInstanceCount.load(), 0);
|
||||
}
|
||||
|
||||
inline void increment(int &num)
|
||||
|
|
|
|||
|
|
@ -322,17 +322,17 @@ void tst_QtConcurrentRun::recursive()
|
|||
int levels = 15;
|
||||
|
||||
for (int i = 0; i < QThread::idealThreadCount(); ++i) {
|
||||
count = 0;
|
||||
count.store(0);
|
||||
QThreadPool::globalInstance()->setMaxThreadCount(i);
|
||||
recursiveRun(levels);
|
||||
QCOMPARE((int)count, (int)pow(2.0, levels) - 1);
|
||||
QCOMPARE(count.load(), (int)pow(2.0, levels) - 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < QThread::idealThreadCount(); ++i) {
|
||||
count = 0;
|
||||
count.store(0);
|
||||
QThreadPool::globalInstance()->setMaxThreadCount(i);
|
||||
recursiveResult(levels);
|
||||
QCOMPARE((int)count, (int)pow(2.0, levels) - 1);
|
||||
QCOMPARE(count.load(), (int)pow(2.0, levels) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class ThrottleAlwaysUser : public ThreadEngine<void>
|
|||
public:
|
||||
ThrottleAlwaysUser()
|
||||
{
|
||||
count = initialCount = 100;
|
||||
count.store(initialCount = 100);
|
||||
finishing = false;
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ public:
|
|||
ThreadFunctionResult threadFunction()
|
||||
{
|
||||
forever {
|
||||
const int local = count;
|
||||
const int local = count.load();
|
||||
if (local == 0) {
|
||||
finishing = true;
|
||||
return ThreadFinished;
|
||||
|
|
@ -237,13 +237,13 @@ void tst_QtConcurrentThreadEngine::throttle()
|
|||
for (int i = 0; i < repeats; ++i) {
|
||||
QFuture<void> f = (new ThrottleAlwaysUser())->startAsynchronously();
|
||||
f.waitForFinished();
|
||||
QCOMPARE(int(count), 0);
|
||||
QCOMPARE(count.load(), 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < repeats; ++i) {
|
||||
ThrottleAlwaysUser t;
|
||||
t.startBlocking();
|
||||
QCOMPARE(int(count), 0);
|
||||
QCOMPARE(count.load(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -620,14 +620,14 @@ class CountingRunnable : public QRunnable
|
|||
void tst_QThreadPool::start()
|
||||
{
|
||||
const int runs = 1000;
|
||||
count = 0;
|
||||
count.store(0);
|
||||
{
|
||||
QThreadPool threadPool;
|
||||
for (int i = 0; i< runs; ++i) {
|
||||
threadPool.start(new CountingRunnable());
|
||||
}
|
||||
}
|
||||
QCOMPARE(int(count), runs);
|
||||
QCOMPARE(count.load(), runs);
|
||||
}
|
||||
|
||||
void tst_QThreadPool::tryStart()
|
||||
|
|
@ -646,7 +646,7 @@ void tst_QThreadPool::tryStart()
|
|||
}
|
||||
};
|
||||
|
||||
count = 0;
|
||||
count.store(0);
|
||||
|
||||
WaitingTask task;
|
||||
QThreadPool threadPool;
|
||||
|
|
@ -656,7 +656,7 @@ void tst_QThreadPool::tryStart()
|
|||
QVERIFY(!threadPool.tryStart(&task));
|
||||
task.semaphore.release(threadPool.maxThreadCount());
|
||||
threadPool.waitForDone();
|
||||
QCOMPARE(int(count), threadPool.maxThreadCount());
|
||||
QCOMPARE(count.load(), threadPool.maxThreadCount());
|
||||
}
|
||||
|
||||
QMutex mutex;
|
||||
|
|
@ -736,16 +736,16 @@ void tst_QThreadPool::waitForDone()
|
|||
QThreadPool threadPool;
|
||||
while (total.elapsed() < 10000) {
|
||||
int runs;
|
||||
runs = count = 0;
|
||||
count.store(runs = 0);
|
||||
pass.restart();
|
||||
while (pass.elapsed() < 100) {
|
||||
threadPool.start(new CountingRunnable());
|
||||
++runs;
|
||||
}
|
||||
threadPool.waitForDone();
|
||||
QCOMPARE(int(count), runs);
|
||||
QCOMPARE(count.load(), runs);
|
||||
|
||||
runs = count = 0;
|
||||
count.store(runs = 0);
|
||||
pass.restart();
|
||||
while (pass.elapsed() < 100) {
|
||||
threadPool.start(new CountingRunnable());
|
||||
|
|
@ -753,7 +753,7 @@ void tst_QThreadPool::waitForDone()
|
|||
runs += 2;
|
||||
}
|
||||
threadPool.waitForDone();
|
||||
QCOMPARE(int(count), runs);
|
||||
QCOMPARE(count.load(), runs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -790,7 +790,7 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish()
|
|||
|
||||
while (total.elapsed() < 10000) {
|
||||
int runs;
|
||||
runs = count = 0;
|
||||
count.store(runs = 0);
|
||||
{
|
||||
QThreadPool threadPool;
|
||||
pass.restart();
|
||||
|
|
@ -799,9 +799,9 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish()
|
|||
++runs;
|
||||
}
|
||||
}
|
||||
QCOMPARE(int(count), runs);
|
||||
QCOMPARE(count.load(), runs);
|
||||
|
||||
runs = count = 0;
|
||||
count.store(runs = 0);
|
||||
{
|
||||
QThreadPool threadPool;
|
||||
pass.restart();
|
||||
|
|
@ -811,7 +811,7 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish()
|
|||
runs += 2;
|
||||
}
|
||||
}
|
||||
QCOMPARE(int(count), runs);
|
||||
QCOMPARE(count.load(), runs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,9 +161,9 @@ void tst_QAtomicInt::constructor()
|
|||
{
|
||||
QFETCH(int, value);
|
||||
QAtomicInt atomic1(value);
|
||||
QCOMPARE(int(atomic1), value);
|
||||
QCOMPARE(atomic1.load(), value);
|
||||
QAtomicInt atomic2 = value;
|
||||
QCOMPARE(int(atomic2), value);
|
||||
QCOMPARE(atomic2.load(), value);
|
||||
}
|
||||
|
||||
void tst_QAtomicInt::copy_constructor_data()
|
||||
|
|
@ -173,16 +173,16 @@ void tst_QAtomicInt::copy_constructor()
|
|||
{
|
||||
QFETCH(int, value);
|
||||
QAtomicInt atomic1(value);
|
||||
QCOMPARE(int(atomic1), value);
|
||||
QCOMPARE(atomic1.load(), value);
|
||||
|
||||
QAtomicInt atomic2(atomic1);
|
||||
QCOMPARE(int(atomic2), value);
|
||||
QCOMPARE(atomic2.load(), value);
|
||||
QAtomicInt atomic3 = atomic1;
|
||||
QCOMPARE(int(atomic3), value);
|
||||
QCOMPARE(atomic3.load(), value);
|
||||
QAtomicInt atomic4(atomic2);
|
||||
QCOMPARE(int(atomic4), value);
|
||||
QCOMPARE(atomic4.load(), value);
|
||||
QAtomicInt atomic5 = atomic2;
|
||||
QCOMPARE(int(atomic5), value);
|
||||
QCOMPARE(atomic5.load(), value);
|
||||
}
|
||||
|
||||
void tst_QAtomicInt::equality_operator_data()
|
||||
|
|
@ -274,9 +274,10 @@ void tst_QAtomicInt::assignment_operator()
|
|||
QCOMPARE(int(atomic1), newval);
|
||||
atomic1 = value;
|
||||
QCOMPARE(int(atomic1), value);
|
||||
|
||||
QAtomicInt atomic2 = newval;
|
||||
atomic1 = atomic2;
|
||||
QCOMPARE(atomic1, atomic2);
|
||||
QCOMPARE(atomic1.load(), atomic2.load());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +345,7 @@ void tst_QAtomicInt::ref()
|
|||
QFETCH(int, value);
|
||||
QAtomicInt x = value;
|
||||
QTEST(x.ref() ? 1 : 0, "result");
|
||||
QTEST(int(x), "expected");
|
||||
QTEST(x.load(), "expected");
|
||||
}
|
||||
|
||||
void tst_QAtomicInt::deref_data()
|
||||
|
|
@ -363,7 +364,7 @@ void tst_QAtomicInt::deref()
|
|||
QFETCH(int, value);
|
||||
QAtomicInt x = value;
|
||||
QTEST(x.deref() ? 1 : 0, "result");
|
||||
QTEST(int(x), "expected");
|
||||
QTEST(x.load(), "expected");
|
||||
}
|
||||
|
||||
void tst_QAtomicInt::isTestAndSetNative()
|
||||
|
|
@ -542,25 +543,25 @@ void tst_QAtomicInt::fetchAndStore()
|
|||
{
|
||||
QAtomicInt atomic = value;
|
||||
QCOMPARE(atomic.fetchAndStoreRelaxed(newval), value);
|
||||
QCOMPARE(int(atomic), newval);
|
||||
QCOMPARE(atomic.load(), newval);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicInt atomic = value;
|
||||
QCOMPARE(atomic.fetchAndStoreAcquire(newval), value);
|
||||
QCOMPARE(int(atomic), newval);
|
||||
QCOMPARE(atomic.load(), newval);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicInt atomic = value;
|
||||
QCOMPARE(atomic.fetchAndStoreRelease(newval), value);
|
||||
QCOMPARE(int(atomic), newval);
|
||||
QCOMPARE(atomic.load(), newval);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicInt atomic = value;
|
||||
QCOMPARE(atomic.fetchAndStoreOrdered(newval), value);
|
||||
QCOMPARE(int(atomic), newval);
|
||||
QCOMPARE(atomic.load(), newval);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -679,28 +680,28 @@ void tst_QAtomicInt::fetchAndAdd()
|
|||
QAtomicInt atomic = value1;
|
||||
result = atomic.fetchAndAddRelaxed(value2);
|
||||
QCOMPARE(result, value1);
|
||||
QCOMPARE(int(atomic), value1 + value2);
|
||||
QCOMPARE(atomic.load(), value1 + value2);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicInt atomic = value1;
|
||||
result = atomic.fetchAndAddAcquire(value2);
|
||||
QCOMPARE(result, value1);
|
||||
QCOMPARE(int(atomic), value1 + value2);
|
||||
QCOMPARE(atomic.load(), value1 + value2);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicInt atomic = value1;
|
||||
result = atomic.fetchAndAddRelease(value2);
|
||||
QCOMPARE(result, value1);
|
||||
QCOMPARE(int(atomic), value1 + value2);
|
||||
QCOMPARE(atomic.load(), value1 + value2);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicInt atomic = value1;
|
||||
result = atomic.fetchAndAddOrdered(value2);
|
||||
QCOMPARE(result, value1);
|
||||
QCOMPARE(int(atomic), value1 + value2);
|
||||
QCOMPARE(atomic.load(), value1 + value2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -713,7 +714,8 @@ void tst_QAtomicInt::testAndSet_loop()
|
|||
|
||||
QAtomicInt val=0;
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
QVERIFY(val.testAndSetRelaxed(val, val+1));
|
||||
int v = val.load();
|
||||
QVERIFY(val.testAndSetRelaxed(v, v+1));
|
||||
if ((i % 1000) == 999) {
|
||||
if (stopWatch.elapsed() > 60 * 1000) {
|
||||
// This test shouldn't run for more than two minutes.
|
||||
|
|
@ -735,7 +737,7 @@ void tst_QAtomicInt::fetchAndAdd_loop()
|
|||
QAtomicInt val=0;
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
const int prev = val.fetchAndAddRelaxed(1);
|
||||
QCOMPARE(prev, int(val) -1);
|
||||
QCOMPARE(prev, val.load() -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -773,7 +775,7 @@ void tst_QAtomicInt::fetchAndAdd_threadedLoop()
|
|||
t1.wait();
|
||||
t2.wait();
|
||||
|
||||
QCOMPARE(int(val), 0);
|
||||
QCOMPARE(val.load(), 0);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAtomicInt)
|
||||
|
|
|
|||
|
|
@ -124,15 +124,15 @@ void tst_QAtomicPointer::constructor()
|
|||
{
|
||||
void *one = this;
|
||||
QAtomicPointer<void> atomic1 = one;
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic1.load() == one);
|
||||
|
||||
void *two = &one;
|
||||
QAtomicPointer<void> atomic2 = two;
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic2.load() == two);
|
||||
|
||||
void *three = &two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
QVERIFY(atomic3 == three);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
}
|
||||
|
||||
void tst_QAtomicPointer::copy_constructor()
|
||||
|
|
@ -140,20 +140,20 @@ void tst_QAtomicPointer::copy_constructor()
|
|||
void *one = this;
|
||||
QAtomicPointer<void> atomic1 = one;
|
||||
QAtomicPointer<void> atomic1_copy = atomic1;
|
||||
QVERIFY(atomic1_copy == one);
|
||||
QCOMPARE(atomic1_copy, atomic1);
|
||||
QVERIFY(atomic1_copy.load() == one);
|
||||
QCOMPARE(atomic1_copy.load(), atomic1.load());
|
||||
|
||||
void *two = &one;
|
||||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic2_copy = atomic2;
|
||||
QVERIFY(atomic2_copy == two);
|
||||
QCOMPARE(atomic2_copy, atomic2);
|
||||
QVERIFY(atomic2_copy.load() == two);
|
||||
QCOMPARE(atomic2_copy.load(), atomic2.load());
|
||||
|
||||
void *three = &two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
QAtomicPointer<void> atomic3_copy = atomic3;
|
||||
QVERIFY(atomic3_copy == three);
|
||||
QCOMPARE(atomic3_copy, atomic3);
|
||||
QVERIFY(atomic3_copy.load() == three);
|
||||
QCOMPARE(atomic3_copy.load(), atomic3.load());
|
||||
}
|
||||
|
||||
void tst_QAtomicPointer::equality_operator()
|
||||
|
|
@ -305,17 +305,17 @@ void tst_QAtomicPointer::testAndSet()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QVERIFY(atomic1.testAndSetRelaxed(one, two));
|
||||
QVERIFY(atomic2.testAndSetRelaxed(two, three));
|
||||
QVERIFY(atomic3.testAndSetRelaxed(three, one));
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -323,17 +323,17 @@ void tst_QAtomicPointer::testAndSet()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QVERIFY(atomic1.testAndSetAcquire(one, two));
|
||||
QVERIFY(atomic2.testAndSetAcquire(two, three));
|
||||
QVERIFY(atomic3.testAndSetAcquire(three, one));
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -341,17 +341,17 @@ void tst_QAtomicPointer::testAndSet()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QVERIFY(atomic1.testAndSetRelease(one, two));
|
||||
QVERIFY(atomic2.testAndSetRelease(two, three));
|
||||
QVERIFY(atomic3.testAndSetRelease(three, one));
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -359,17 +359,17 @@ void tst_QAtomicPointer::testAndSet()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QVERIFY(atomic1.testAndSetOrdered(one, two));
|
||||
QVERIFY(atomic2.testAndSetOrdered(two, three));
|
||||
QVERIFY(atomic3.testAndSetOrdered(three, one));
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -433,17 +433,17 @@ void tst_QAtomicPointer::fetchAndStore()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QCOMPARE(atomic1.fetchAndStoreRelaxed(two), one);
|
||||
QCOMPARE(atomic2.fetchAndStoreRelaxed(three), two);
|
||||
QCOMPARE(atomic3.fetchAndStoreRelaxed(one), three);
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -451,17 +451,17 @@ void tst_QAtomicPointer::fetchAndStore()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QCOMPARE(atomic1.fetchAndStoreAcquire(two), one);
|
||||
QCOMPARE(atomic2.fetchAndStoreAcquire(three), two);
|
||||
QCOMPARE(atomic3.fetchAndStoreAcquire(one), three);
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -469,17 +469,17 @@ void tst_QAtomicPointer::fetchAndStore()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QCOMPARE(atomic1.fetchAndStoreRelease(two), one);
|
||||
QCOMPARE(atomic2.fetchAndStoreRelease(three), two);
|
||||
QCOMPARE(atomic3.fetchAndStoreRelease(one), three);
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -487,17 +487,17 @@ void tst_QAtomicPointer::fetchAndStore()
|
|||
QAtomicPointer<void> atomic2 = two;
|
||||
QAtomicPointer<void> atomic3 = three;
|
||||
|
||||
QVERIFY(atomic1 == one);
|
||||
QVERIFY(atomic2 == two);
|
||||
QVERIFY(atomic3 == three);
|
||||
QCOMPARE(atomic1.load(), one);
|
||||
QCOMPARE(atomic2.load(), two);
|
||||
QVERIFY(atomic3.load() == three);
|
||||
|
||||
QCOMPARE(atomic1.fetchAndStoreOrdered(two), one);
|
||||
QCOMPARE(atomic2.fetchAndStoreOrdered(three), two);
|
||||
QCOMPARE(atomic3.fetchAndStoreOrdered(one), three);
|
||||
|
||||
QVERIFY(atomic1 == two);
|
||||
QVERIFY(atomic2 == three);
|
||||
QVERIFY(atomic3 == one);
|
||||
QVERIFY(atomic1.load() == two);
|
||||
QVERIFY(atomic2.load() == three);
|
||||
QVERIFY(atomic3.load() == one);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -598,62 +598,62 @@ void tst_QAtomicPointer::fetchAndAdd()
|
|||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddRelaxed(valueToAdd)), quintptr(pc));
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddRelaxed(-valueToAdd)), quintptr(pc + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<char *>(pointer1)), quintptr(pc));
|
||||
QCOMPARE(pointer1.fetchAndAddRelaxed(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddRelaxed(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddRelaxed(valueToAdd)), quintptr(ps));
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddRelaxed(-valueToAdd)), quintptr(ps + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<short *>(pointer2)), quintptr(ps));
|
||||
QCOMPARE(pointer2.fetchAndAddRelaxed(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddRelaxed(-valueToAdd), ps + valueToAdd);
|
||||
QCOMPARE(pointer2.load(), ps);
|
||||
QAtomicPointer<int> pointer3 = pi;
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddRelaxed(valueToAdd)), quintptr(pi));
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddRelaxed(-valueToAdd)), quintptr(pi + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<int *>(pointer3)), quintptr(pi));
|
||||
QCOMPARE(pointer3.fetchAndAddRelaxed(valueToAdd), pi);
|
||||
QCOMPARE(pointer3.fetchAndAddRelaxed(-valueToAdd), pi + valueToAdd);
|
||||
QCOMPARE(pointer3.load(), pi);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddAcquire(valueToAdd)), quintptr(pc));
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddAcquire(-valueToAdd)), quintptr(pc + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<char *>(pointer1)), quintptr(pc));
|
||||
QCOMPARE(pointer1.fetchAndAddAcquire(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddAcquire(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddAcquire(valueToAdd)), quintptr(ps));
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddAcquire(-valueToAdd)), quintptr(ps + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<short *>(pointer2)), quintptr(ps));
|
||||
QCOMPARE(pointer2.fetchAndAddAcquire(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddAcquire(-valueToAdd), ps + valueToAdd);
|
||||
QCOMPARE(pointer2.load(), ps);
|
||||
QAtomicPointer<int> pointer3 = pi;
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddAcquire(valueToAdd)), quintptr(pi));
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddAcquire(-valueToAdd)), quintptr(pi + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<int *>(pointer3)), quintptr(pi));
|
||||
QCOMPARE(pointer3.fetchAndAddAcquire(valueToAdd), pi);
|
||||
QCOMPARE(pointer3.fetchAndAddAcquire(-valueToAdd), pi + valueToAdd);
|
||||
QCOMPARE(pointer3.load(), pi);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddRelease(valueToAdd)), quintptr(pc));
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddRelease(-valueToAdd)), quintptr(pc + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<char *>(pointer1)), quintptr(pc));
|
||||
QCOMPARE(pointer1.fetchAndAddRelease(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddRelease(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddRelease(valueToAdd)), quintptr(ps));
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddRelease(-valueToAdd)), quintptr(ps + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<short *>(pointer2)), quintptr(ps));
|
||||
QCOMPARE(pointer2.fetchAndAddRelease(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddRelease(-valueToAdd), ps + valueToAdd);
|
||||
QCOMPARE(pointer2.load(), ps);
|
||||
QAtomicPointer<int> pointer3 = pi;
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddRelease(valueToAdd)), quintptr(pi));
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddRelease(-valueToAdd)), quintptr(pi + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<int *>(pointer3)), quintptr(pi));
|
||||
QCOMPARE(pointer3.fetchAndAddRelease(valueToAdd), pi);
|
||||
QCOMPARE(pointer3.fetchAndAddRelease(-valueToAdd), pi + valueToAdd);
|
||||
QCOMPARE(pointer3.load(), pi);
|
||||
}
|
||||
|
||||
{
|
||||
QAtomicPointer<char> pointer1 = pc;
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddOrdered(valueToAdd)), quintptr(pc));
|
||||
QCOMPARE(quintptr(pointer1.fetchAndAddOrdered(-valueToAdd)), quintptr(pc + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<char *>(pointer1)), quintptr(pc));
|
||||
QCOMPARE(pointer1.fetchAndAddOrdered(valueToAdd), pc);
|
||||
QCOMPARE(pointer1.fetchAndAddOrdered(-valueToAdd), pc + valueToAdd);
|
||||
QCOMPARE(pointer1.load(), pc);
|
||||
QAtomicPointer<short> pointer2 = ps;
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddOrdered(valueToAdd)), quintptr(ps));
|
||||
QCOMPARE(quintptr(pointer2.fetchAndAddOrdered(-valueToAdd)), quintptr(ps + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<short *>(pointer2)), quintptr(ps));
|
||||
QCOMPARE(pointer2.fetchAndAddOrdered(valueToAdd), ps);
|
||||
QCOMPARE(pointer2.fetchAndAddOrdered(-valueToAdd), ps + valueToAdd);
|
||||
QCOMPARE(pointer2.load(), ps);
|
||||
QAtomicPointer<int> pointer3 = pi;
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddOrdered(valueToAdd)), quintptr(pi));
|
||||
QCOMPARE(quintptr(pointer3.fetchAndAddOrdered(-valueToAdd)), quintptr(pi + valueToAdd));
|
||||
QCOMPARE(quintptr(static_cast<int *>(pointer3)), quintptr(pi));
|
||||
QCOMPARE(pointer3.fetchAndAddOrdered(valueToAdd), pi);
|
||||
QCOMPARE(pointer3.fetchAndAddOrdered(-valueToAdd), pi + valueToAdd);
|
||||
QCOMPARE(pointer3.load(), pi);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -617,8 +617,8 @@ void tst_QMutex::moreStress()
|
|||
QVERIFY(threads[0].wait(one_minute + 10000));
|
||||
for (int i = 1; i < threadCount; ++i)
|
||||
QVERIFY(threads[i].wait(10000));
|
||||
qDebug("locked %d times", int(MoreStressTestThread::lockCount));
|
||||
QCOMPARE(int(MoreStressTestThread::errorCount), 0);
|
||||
qDebug("locked %d times", MoreStressTestThread::lockCount.load());
|
||||
QCOMPARE(MoreStressTestThread::errorCount.load(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -123,10 +123,11 @@ public:
|
|||
QAtomicInt activationCount;
|
||||
|
||||
inline SignalRecorder()
|
||||
{ activationCount = 0; }
|
||||
: activationCount(0)
|
||||
{ }
|
||||
|
||||
bool wasActivated()
|
||||
{ return activationCount > 0; }
|
||||
{ return activationCount.load() > 0; }
|
||||
|
||||
public slots:
|
||||
void slot();
|
||||
|
|
@ -907,7 +908,7 @@ void tst_QThread::adoptMultipleThreads()
|
|||
|
||||
QTestEventLoop::instance().enterLoop(5);
|
||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||
QCOMPARE(int(recorder.activationCount), numThreads);
|
||||
QCOMPARE(recorder.activationCount.load(), numThreads);
|
||||
}
|
||||
|
||||
void tst_QThread::adoptMultipleThreadsOverlap()
|
||||
|
|
@ -949,7 +950,7 @@ void tst_QThread::adoptMultipleThreadsOverlap()
|
|||
|
||||
QTestEventLoop::instance().enterLoop(5);
|
||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||
QCOMPARE(int(recorder.activationCount), numThreads);
|
||||
QCOMPARE(recorder.activationCount.load(), numThreads);
|
||||
}
|
||||
|
||||
// Disconnects on WinCE, so skip this test.
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ struct RefCounted
|
|||
|
||||
~RefCounted()
|
||||
{
|
||||
QVERIFY( ref == 0 );
|
||||
QVERIFY( ref.load() == 0 );
|
||||
instanceCount.deref();
|
||||
}
|
||||
|
||||
|
|
@ -372,13 +372,13 @@ void scopedPointerComparisonTest(const A1 &a1, const A2 &a2, const B &b)
|
|||
|
||||
void tst_QScopedPointer::comparison()
|
||||
{
|
||||
QCOMPARE( int(RefCounted::instanceCount), 0 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 0 );
|
||||
|
||||
{
|
||||
RefCounted *a = new RefCounted;
|
||||
RefCounted *b = new RefCounted;
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 2 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 2 );
|
||||
|
||||
QScopedPointer<RefCounted> pa1(a);
|
||||
QScopedPointer<RefCounted> pa2(a);
|
||||
|
|
@ -390,16 +390,16 @@ void tst_QScopedPointer::comparison()
|
|||
|
||||
pa2.take();
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 2 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 2 );
|
||||
}
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 0 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 0 );
|
||||
|
||||
{
|
||||
RefCounted *a = new RefCounted[42];
|
||||
RefCounted *b = new RefCounted[43];
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 85 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 85 );
|
||||
|
||||
QScopedArrayPointer<RefCounted> pa1(a);
|
||||
QScopedArrayPointer<RefCounted> pa2(a);
|
||||
|
|
@ -409,10 +409,10 @@ void tst_QScopedPointer::comparison()
|
|||
|
||||
pa2.take();
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 85 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 85 );
|
||||
}
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 0 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 0 );
|
||||
|
||||
{
|
||||
// QScopedSharedPointer is an internal helper class -- it is unsupported!
|
||||
|
|
@ -420,42 +420,42 @@ void tst_QScopedPointer::comparison()
|
|||
RefCounted *a = new RefCounted;
|
||||
RefCounted *b = new RefCounted;
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 2 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 2 );
|
||||
|
||||
QSharedDataPointer<RefCounted> pa1(a);
|
||||
QSharedDataPointer<RefCounted> pa2(a);
|
||||
QSharedDataPointer<RefCounted> pb(b);
|
||||
|
||||
QCOMPARE( int(a->ref), 2 );
|
||||
QCOMPARE( int(b->ref), 1 );
|
||||
QCOMPARE( int(RefCounted::instanceCount), 2 );
|
||||
QCOMPARE( a->ref.load(), 2 );
|
||||
QCOMPARE( b->ref.load(), 1 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 2 );
|
||||
|
||||
scopedPointerComparisonTest(pa1, pa2, pb);
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 2 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 2 );
|
||||
}
|
||||
|
||||
QCOMPARE( int(RefCounted::instanceCount), 0 );
|
||||
QCOMPARE( RefCounted::instanceCount.load(), 0 );
|
||||
}
|
||||
|
||||
void tst_QScopedPointer::array()
|
||||
{
|
||||
int instCount = RefCounted::instanceCount;
|
||||
int instCount = RefCounted::instanceCount.load();
|
||||
{
|
||||
QScopedArrayPointer<RefCounted> array;
|
||||
array.reset(new RefCounted[42]);
|
||||
QCOMPARE(instCount + 42, int(RefCounted::instanceCount));
|
||||
QCOMPARE(instCount + 42, RefCounted::instanceCount.load());
|
||||
}
|
||||
QCOMPARE(instCount, int(RefCounted::instanceCount));
|
||||
QCOMPARE(instCount, RefCounted::instanceCount.load());
|
||||
{
|
||||
QScopedArrayPointer<RefCounted> array(new RefCounted[42]);
|
||||
QCOMPARE(instCount + 42, int(RefCounted::instanceCount));
|
||||
QCOMPARE(instCount + 42, RefCounted::instanceCount.load());
|
||||
array.reset(new RefCounted[28]);
|
||||
QCOMPARE(instCount + 28, int(RefCounted::instanceCount));
|
||||
QCOMPARE(instCount + 28, RefCounted::instanceCount.load());
|
||||
array.reset(0);
|
||||
QCOMPARE(instCount, int(RefCounted::instanceCount));
|
||||
QCOMPARE(instCount, RefCounted::instanceCount.load());
|
||||
}
|
||||
QCOMPARE(instCount, int(RefCounted::instanceCount));
|
||||
QCOMPARE(instCount, RefCounted::instanceCount.load());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1509,7 +1509,7 @@ void tst_QSharedPointer::threadStressTest()
|
|||
for (int r = 0; r < 5; ++r) {
|
||||
QVector<QThread*> allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0);
|
||||
QSharedPointer<ThreadData> base = QSharedPointer<ThreadData>(new ThreadData(&counter));
|
||||
counter = 0;
|
||||
counter.store(0);
|
||||
|
||||
// set the pointers
|
||||
for (int i = 0; i < strongThreadCount; ++i) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue