summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qsharedpointer_impl.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago@kde.org>2011-07-05 23:46:19 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-03 07:57:41 +0200
commit5bfeab8749ce6820d55135b81665a7231d3b1504 (patch)
tree152569571114c53d4cdfaa0013307267cb3379a6 /src/corelib/tools/qsharedpointer_impl.h
parent5613c9722adee921e16682c0a035f2a7567bd346 (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 'src/corelib/tools/qsharedpointer_impl.h')
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 47ad21a499..f03889106f 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -186,11 +186,11 @@ namespace QtSharedPointer {
inline ExternalRefCountData()
{
- strongref = 1;
- weakref = 1;
+ strongref.store(1);
+ weakref.store(1);
}
inline ExternalRefCountData(Qt::Initialization) { }
- virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(strongref <= 0); }
+ virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref.load()); Q_ASSERT(strongref.load() <= 0); }
// overridden by derived classes
// returns false to indicate caller should delete the pointer
@@ -432,12 +432,12 @@ namespace QtSharedPointer {
if (o) {
// increase the strongref, but never up from zero
// or less (-1 is used by QWeakPointer on untracked QObject)
- register int tmp = o->strongref;
+ register int tmp = o->strongref.load();
while (tmp > 0) {
// try to increment from "tmp" to "tmp + 1"
if (o->strongref.testAndSetRelaxed(tmp, tmp + 1))
break; // succeeded
- tmp = o->strongref; // failed, try again
+ tmp = o->strongref.load(); // failed, try again
}
if (tmp > 0)
@@ -448,7 +448,7 @@ namespace QtSharedPointer {
qSwap(d, o);
qSwap(this->value, actual);
- if (!d || d->strongref == 0)
+ if (!d || d->strongref.load() == 0)
this->value = 0;
// dereference saved data
@@ -577,14 +577,14 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- inline bool isNull() const { return d == 0 || d->strongref == 0 || value == 0; }
+ inline bool isNull() const { return d == 0 || d->strongref.load() == 0 || value == 0; }
#ifndef Q_CC_NOKIAX86
inline operator RestrictedBool() const { return isNull() ? 0 : &QWeakPointer::value; }
#else
inline operator bool() const { return isNull() ? 0 : &QWeakPointer::value; }
#endif
inline bool operator !() const { return isNull(); }
- inline T *data() const { return d == 0 || d->strongref == 0 ? 0 : value; }
+ inline T *data() const { return d == 0 || d->strongref.load() == 0 ? 0 : value; }
inline QWeakPointer() : d(0), value(0) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }