summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qatomic.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2019-06-06 12:27:26 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2019-06-10 16:56:17 +0000
commit620f12120618ae548575c741a9dc54e405aefed4 (patch)
tree54ac78189cd5a35785e898e6aafb5bb90a3bd4cb /src/corelib/thread/qatomic.h
parentefe1073e440fd7a179da8d19abc43fb9a745ac2f (diff)
QAtomic: introduce loadRelaxed() / storeRelaxed()
Plain load() / store() have already relaxed semantics. This can be surprising -- std::atomic::load()/store() are actually sequentially consistent -- and introduce a pain point if someone wants to move from Qt atomics to std:: atomics. So just add a suffix to the functions to clarify what's the memory ordering involved with them. The Ops::load / ::store are temporarily left in, because other modules depends on them. We need to port those modules away, then they can go (it's private API anyhow). Similarly, not deprecating anything yet, except for marking obsolete in the docs; there's a lot of code around using load() / store() that needs to be ported first. [ChangeLog][QtCore][QAtomicInteger] Added loadRelaxed() and storeRelaxed(), to be used as replacements of load() / store(). [ChangeLog][QtCore][QAtomicPointer] Added loadRelaxed() and storeRelaxed(), to be used as replacements of load() / store(). Change-Id: Iab0a78885050379e3740f0b039ba2bef28ce3bd2 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qatomic.h')
-rw-r--r--src/corelib/thread/qatomic.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h
index 280ce96b76..7990db2fd9 100644
--- a/src/corelib/thread/qatomic.h
+++ b/src/corelib/thread/qatomic.h
@@ -81,8 +81,10 @@ public:
#ifdef Q_CLANG_QDOC
T load() const;
+ T loadRelaxed() const;
T loadAcquire() const;
void store(T newValue);
+ void storeRelaxed(T newValue);
void storeRelease(T newValue);
operator T() const;
@@ -172,7 +174,7 @@ public:
#else
inline QAtomicPointer(T *value = nullptr) noexcept
{
- this->store(value);
+ this->storeRelaxed(value);
}
#endif
inline QAtomicPointer(const QAtomicPointer<T> &other) noexcept