diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-06-26 11:32:55 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-06-26 11:33:19 +0200 |
commit | 7810209ba32fcebfa90b081670595daaa5333a78 (patch) | |
tree | 98410d5cc7d9d762bbde0cb4eae8041aa6e2e542 /src/corelib/global/qglobalstatic.h | |
parent | 6f2eabb54e3f827ebd2b90f68144b86342933869 (diff) | |
parent | 88625709058b386ee74cca536c6c5556159c99fa (diff) |
Merge remote-tracking branch 'origin/dev' into wip/qt6
Change-Id: I4ea2b77cc201daed94fbe321f146dfd20365a534
Diffstat (limited to 'src/corelib/global/qglobalstatic.h')
-rw-r--r-- | src/corelib/global/qglobalstatic.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 4f89876793..7a7d65ed76 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -80,15 +80,15 @@ enum GuardValues { { \ struct HolderBase { \ ~HolderBase() noexcept \ - { if (guard.load() == QtGlobalStatic::Initialized) \ - guard.store(QtGlobalStatic::Destroyed); } \ + { if (guard.loadRelaxed() == QtGlobalStatic::Initialized) \ + guard.storeRelaxed(QtGlobalStatic::Destroyed); } \ }; \ static struct Holder : public HolderBase { \ Type value; \ Holder() \ noexcept(noexcept(Type ARGS)) \ : value ARGS \ - { guard.store(QtGlobalStatic::Initialized); } \ + { guard.storeRelaxed(QtGlobalStatic::Initialized); } \ } holder; \ return &holder.value; \ } @@ -108,12 +108,12 @@ QT_BEGIN_NAMESPACE int x = guard.loadAcquire(); \ if (Q_UNLIKELY(x >= QtGlobalStatic::Uninitialized)) { \ QMutexLocker locker(&mutex); \ - if (guard.load() == QtGlobalStatic::Uninitialized) { \ + if (guard.loadRelaxed() == QtGlobalStatic::Uninitialized) { \ d = new Type ARGS; \ static struct Cleanup { \ ~Cleanup() { \ delete d; \ - guard.store(QtGlobalStatic::Destroyed); \ + guard.storeRelaxed(QtGlobalStatic::Destroyed); \ } \ } cleanup; \ guard.storeRelease(QtGlobalStatic::Initialized); \ @@ -129,8 +129,8 @@ struct QGlobalStatic { typedef T Type; - bool isDestroyed() const { return guard.load() <= QtGlobalStatic::Destroyed; } - bool exists() const { return guard.load() == QtGlobalStatic::Initialized; } + bool isDestroyed() const { return guard.loadRelaxed() <= QtGlobalStatic::Destroyed; } + bool exists() const { return guard.loadRelaxed() == QtGlobalStatic::Initialized; } operator Type *() { if (isDestroyed()) return nullptr; return innerFunction(); } Type *operator()() { if (isDestroyed()) return nullptr; return innerFunction(); } Type *operator->() |