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 /src/corelib/tools/qcontiguouscache.h | |
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 'src/corelib/tools/qcontiguouscache.h')
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 526d8fbc17..e192edf0ab 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -105,8 +105,8 @@ public: inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) free(p); } - inline void detach() { if (d->ref != 1) detach_helper(); } - inline bool isDetached() const { return d->ref == 1; } + inline void detach() { if (d->ref.load() != 1) detach_helper(); } + inline bool isDetached() const { return d->ref.load() == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } QContiguousCache<T> &operator=(const QContiguousCache<T> &other); @@ -185,7 +185,7 @@ void QContiguousCache<T>::detach_helper() union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x; x.d = malloc(d->alloc); - x.d->ref = 1; + x.d->ref.store(1); x.d->count = d->count; x.d->start = d->start; x.d->offset = d->offset; @@ -258,7 +258,7 @@ void QContiguousCache<T>::setCapacity(int asize) template <typename T> void QContiguousCache<T>::clear() { - if (d->ref == 1) { + if (d->ref.load() == 1) { if (QTypeInfo<T>::isComplex) { int oldcount = d->count; T * i = p->array + d->start; @@ -274,7 +274,7 @@ void QContiguousCache<T>::clear() } else { union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x; x.d = malloc(d->alloc); - x.d->ref = 1; + x.d->ref.store(1); x.d->alloc = d->alloc; x.d->count = x.d->start = x.d->offset = 0; x.d->sharable = true; @@ -293,7 +293,7 @@ template <typename T> QContiguousCache<T>::QContiguousCache(int cap) { d = malloc(cap); - d->ref = 1; + d->ref.store(1); d->alloc = cap; d->count = d->start = d->offset = 0; d->sharable = true; |