diff options
Diffstat (limited to 'src/corelib/thread/qatomic.h')
-rw-r--r-- | src/corelib/thread/qatomic.h | 83 |
1 files changed, 11 insertions, 72 deletions
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index 2080167d2c..7fe5ac69b9 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -1,44 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/qglobal.h> +// Copyright (C) 2017 The Qt Company Ltd. +// 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 #ifndef QATOMIC_H #define QATOMIC_H @@ -50,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()); } @@ -83,7 +32,7 @@ public: return *this; } -#ifdef Q_CLANG_QDOC +#ifdef Q_QDOC T loadRelaxed() const; T loadAcquire() const; void storeRelaxed(T newValue); @@ -106,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(); @@ -160,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 @@ -171,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()); } @@ -227,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: |