diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/corelib/thread/qatomic.cpp | 27 | ||||
| -rw-r--r-- | src/corelib/thread/qatomic.h | 34 | ||||
| -rw-r--r-- | src/corelib/thread/qbasicatomic.h | 4 |
3 files changed, 7 insertions, 58 deletions
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp index 4843556eb50..948f30bb989 100644 --- a/src/corelib/thread/qatomic.cpp +++ b/src/corelib/thread/qatomic.cpp @@ -211,20 +211,6 @@ */ /*! - \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(const QAtomicInteger &other) - - Constructs a copy of \a other. -*/ - -/*! - \fn template <typename T> QAtomicInteger &QAtomicInteger<T>::operator=(const QAtomicInteger &other) - - Assigns \a other to this QAtomicInteger and returns a reference to - this QAtomicInteger. -*/ - - -/*! \fn template <typename T> T QAtomicInteger<T>::loadRelaxed() const \since 5.14 @@ -1369,19 +1355,6 @@ */ /*! - \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(const QAtomicPointer<T> &other) - - Constructs a copy of \a other. -*/ - -/*! - \fn template <typename T> QAtomicPointer &QAtomicPointer<T>::operator=(const QAtomicPointer &other) - - Assigns \a other to this QAtomicPointer and returns a reference to - this QAtomicPointer. -*/ - -/*! \fn template <typename T> T *QAtomicPointer<T>::loadRelaxed() const \since 5.14 diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index 7fe5ac69b9d..26369d28f8f 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -17,20 +17,8 @@ template <typename T> class QAtomicInteger : public QBasicAtomicInteger<T> { public: - // Non-atomic API constexpr QAtomicInteger(T value = 0) noexcept : QBasicAtomicInteger<T>(value) {} - - inline QAtomicInteger(const QAtomicInteger &other) noexcept - : QBasicAtomicInteger<T>() - { - this->storeRelease(other.loadAcquire()); - } - - inline QAtomicInteger &operator=(const QAtomicInteger &other) noexcept - { - this->storeRelease(other.loadAcquire()); - return *this; - } + using QBasicAtomicInteger<T>::operator=; #ifdef Q_QDOC T loadRelaxed() const; @@ -108,13 +96,12 @@ public: #endif }; +// ### Qt 7: make QAtomicInt a typedef class QAtomicInt : public QAtomicInteger<int> { 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. - constexpr QAtomicInt(int value = 0) noexcept : QAtomicInteger<int>(value) {} + using QAtomicInteger<int>::QAtomicInteger; + using QAtomicInteger<int>::operator=; }; // High-level atomic pointer operations @@ -123,18 +110,7 @@ class QAtomicPointer : public QBasicAtomicPointer<T> { public: constexpr QAtomicPointer(T *value = nullptr) noexcept : QBasicAtomicPointer<T>(value) {} - - inline QAtomicPointer(const QAtomicPointer<T> &other) noexcept - : QBasicAtomicPointer<T>() - { - this->storeRelease(other.loadAcquire()); - } - - inline QAtomicPointer<T> &operator=(const QAtomicPointer<T> &other) noexcept - { - this->storeRelease(other.loadAcquire()); - return *this; - } + using QBasicAtomicPointer<T>::operator=; #ifdef Q_QDOC T *loadAcquire() const; diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 6d061ea49a4..4dd67f57c3e 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -39,7 +39,7 @@ public: T loadAcquire() const noexcept { return Ops::loadAcquire(_q_value); } void storeRelease(T newValue) noexcept { Ops::storeRelease(_q_value, newValue); } operator T() const noexcept { return loadAcquire(); } - T operator=(T newValue) noexcept { storeRelease(newValue); return newValue; } + QBasicAtomicInteger &operator=(T newValue) noexcept { storeRelease(newValue); return *this; } static constexpr bool isReferenceCountingNative() noexcept { return Ops::isReferenceCountingNative(); } static constexpr bool isReferenceCountingWaitFree() noexcept { return Ops::isReferenceCountingWaitFree(); } @@ -171,7 +171,7 @@ public: void storeRelaxed(Type newValue) noexcept { Ops::storeRelaxed(_q_value, newValue); } operator Type() const noexcept { return loadAcquire(); } - Type operator=(Type newValue) noexcept { storeRelease(newValue); return newValue; } + QBasicAtomicPointer &operator=(Type newValue) noexcept { storeRelease(newValue); return *this; } // Atomic API, implemented in qatomic_XXX.h Type loadAcquire() const noexcept { return Ops::loadAcquire(_q_value); } |
