diff options
Diffstat (limited to 'src/corelib/thread/qatomic.h')
-rw-r--r-- | src/corelib/thread/qatomic.h | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index 78eff2a710..1bfadc4442 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -55,25 +55,29 @@ QT_BEGIN_NAMESPACE #endif // High-level atomic integer operations -class QAtomicInt : public QBasicAtomicInt +template <typename T> +class QAtomicInteger : public QBasicAtomicInteger<T> { public: // Non-atomic API #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS - constexpr QAtomicInt(int value = 0) Q_DECL_NOTHROW : QBasicAtomicInt(value) {} + constexpr QAtomicInteger(T value = 0) Q_DECL_NOTHROW : QBasicAtomicInteger<T>(value) {} #else - inline QAtomicInt(int value = 0) Q_DECL_NOTHROW + inline QAtomicInteger(T value = 0) Q_DECL_NOTHROW { - _q_value = value; + this->_q_value = value; } #endif - inline QAtomicInt(const QAtomicInt &other) Q_DECL_NOTHROW + inline QAtomicInteger(const QAtomicInteger &other) Q_DECL_NOTHROW +#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS + : QBasicAtomicInteger<T>() +#endif { - store(other.load()); + this->store(other.load()); } - inline QAtomicInt &operator=(const QAtomicInt &other) Q_DECL_NOTHROW + inline QAtomicInteger &operator=(const QAtomicInteger &other) Q_DECL_NOTHROW { this->store(other.load()); return *this; @@ -117,6 +121,18 @@ public: #endif }; +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. +#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS + constexpr +#endif + QAtomicInt(int value = 0) Q_DECL_NOTHROW : QAtomicInteger<int>(value) {} +}; + // High-level atomic pointer operations template <typename T> class QAtomicPointer : public QBasicAtomicPointer<T> |