From 5bfeab8749ce6820d55135b81665a7231d3b1504 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 5 Jul 2011 23:46:19 +0200 Subject: 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 Reviewed-by: Bradley T. Hughes Reviewed-by: Lars Knoll --- src/corelib/tools/qrefcount.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/corelib/tools/qrefcount.h') diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index e72ddf66b6..619f61e072 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -56,27 +56,29 @@ namespace QtPrivate class RefCount { public: - inline void ref() { - if (atomic > 0) + inline void ref() { + if (atomic.load() > 0) atomic.ref(); } inline bool deref() { - if (atomic <= 0) + if (atomic.load() <= 0) return true; return atomic.deref(); } inline bool operator==(int value) const - { return atomic.operator ==(value); } + { return atomic.load() == value; } inline bool operator!=(int value) const - { return atomic.operator !=(value); } + { return atomic.load() != value; } inline bool operator!() const - { return atomic.operator !(); } + { return !atomic.load(); } inline operator int() const - { return atomic.operator int(); } + { return atomic.load(); } inline RefCount &operator=(int value) - { atomic = value; return *this; } + { atomic.store(value); return *this; } + inline RefCount &operator=(const RefCount &other) + { atomic.store(other.atomic.load()); return *this; } QBasicAtomicInt atomic; }; -- cgit v1.2.3