diff options
author | Thiago Macieira <thiago@kde.org> | 2011-07-05 23:46:19 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-03 07:57:41 +0200 |
commit | 5bfeab8749ce6820d55135b81665a7231d3b1504 (patch) | |
tree | 152569571114c53d4cdfaa0013307267cb3379a6 /tests/auto/corelib/thread/qthreadonce | |
parent | 5613c9722adee921e16682c0a035f2a7567bd346 (diff) |
Make all uses of QBasicAtomicInt and Pointer use load() and store()
Most of these changes are search-and-replace of d->ref ==, d->ref !=
and d->ref =.
The QBasicAtomicPointer in QObjectPrivate::Connection didn't need to
be basic, so I made it QAtomicPointer.
Change-Id: Ie3271abd1728af599f9ab17c6f4868e475f17bb6
Reviewed-on: http://codereview.qt-project.org/5030
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/thread/qthreadonce')
-rw-r--r-- | tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp index b23e11b153..abd3d6bbef 100644 --- a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp @@ -75,7 +75,7 @@ QOnceControl::QOnceControl(QBasicAtomicInt *control) d = 0; gv = control; // check if code has already run once - if (*gv == 2) { + if (gv->loadAcquire() == 2) { // uncontended case: it has already initialized // no waiting return; diff --git a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp index 235829b268..041f801672 100644 --- a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp @@ -70,7 +70,7 @@ class SingletonObject: public QObject Q_OBJECT public: static int runCount; - SingletonObject() { val = 42; ++runCount; } + SingletonObject() { val.store(42); ++runCount; } ~SingletonObject() { } QBasicAtomicInt val; @@ -126,7 +126,7 @@ void tst_QThreadOnce::sameThread() QCOMPARE(controlVariable, 1); static QSingleton<SingletonObject> s; - QTEST((int)s->val, "expectedValue"); + QTEST((int)s->val.load(), "expectedValue"); s->val.ref(); QCOMPARE(SingletonObject::runCount, 1); @@ -148,7 +148,7 @@ void tst_QThreadOnce::multipleThreads() QCOMPARE(controlVariable, 0); // nothing must have set them yet SingletonObject::runCount = 0; - IncrementThread::runCount = 0; + IncrementThread::runCount.store(0); // wait for all of them to be ready sem2.acquire(NumberOfThreads); @@ -159,7 +159,7 @@ void tst_QThreadOnce::multipleThreads() delete parent; QCOMPARE(controlVariable, 1); - QCOMPARE((int)IncrementThread::runCount, NumberOfThreads); + QCOMPARE((int)IncrementThread::runCount.load(), NumberOfThreads); QCOMPARE(SingletonObject::runCount, 1); } |