diff options
Diffstat (limited to 'src/corelib/thread/qatomic.h')
-rw-r--r-- | src/corelib/thread/qatomic.h | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index a4c9c23fbe..7fe5ac69b9 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -2,8 +2,6 @@ // Copyright (C) 2016 Intel Corporation. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#include <QtCore/qglobal.h> - #ifndef QATOMIC_H #define QATOMIC_H @@ -14,29 +12,16 @@ QT_BEGIN_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wextra") -#ifdef Q_CLANG_QDOC -# undef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS -#endif - // High-level atomic integer operations template <typename T> class QAtomicInteger : public QBasicAtomicInteger<T> { public: // Non-atomic API -#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS constexpr QAtomicInteger(T value = 0) noexcept : QBasicAtomicInteger<T>(value) {} -#else - inline QAtomicInteger(T value = 0) noexcept - { - this->_q_value = value; - } -#endif inline QAtomicInteger(const QAtomicInteger &other) noexcept -#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS : QBasicAtomicInteger<T>() -#endif { this->storeRelease(other.loadAcquire()); } @@ -47,7 +32,7 @@ public: return *this; } -#ifdef Q_CLANG_QDOC +#ifdef Q_QDOC T loadRelaxed() const; T loadAcquire() const; void storeRelaxed(T newValue); @@ -70,6 +55,11 @@ public: bool testAndSetRelease(T expectedValue, T newValue); bool testAndSetOrdered(T expectedValue, T newValue); + bool testAndSetRelaxed(T expectedValue, T newValue, T ¤tValue); + bool testAndSetAcquire(T expectedValue, T newValue, T ¤tValue); + bool testAndSetRelease(T expectedValue, T newValue, T ¤tValue); + bool testAndSetOrdered(T expectedValue, T newValue, T ¤tValue); + static constexpr bool isFetchAndStoreNative(); static constexpr bool isFetchAndStoreWaitFree(); @@ -124,10 +114,7 @@ public: // Non-atomic API // We could use QT_COMPILER_INHERITING_CONSTRUCTORS, but we need only one; // the implicit definition for all the others is fine. -#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS - constexpr -#endif - QAtomicInt(int value = 0) noexcept : QAtomicInteger<int>(value) {} + constexpr QAtomicInt(int value = 0) noexcept : QAtomicInteger<int>(value) {} }; // High-level atomic pointer operations @@ -135,18 +122,10 @@ template <typename T> class QAtomicPointer : public QBasicAtomicPointer<T> { public: -#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS constexpr QAtomicPointer(T *value = nullptr) noexcept : QBasicAtomicPointer<T>(value) {} -#else - inline QAtomicPointer(T *value = nullptr) noexcept - { - this->storeRelaxed(value); - } -#endif + inline QAtomicPointer(const QAtomicPointer<T> &other) noexcept -#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS : QBasicAtomicPointer<T>() -#endif { this->storeRelease(other.loadAcquire()); } @@ -191,10 +170,6 @@ public: QT_WARNING_POP -#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS -# undef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS -#endif - /*! This is a helper for the assignment operators of implicitly shared classes. Your assignment operator should look like this: |