Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QAtomicInteger< T > Class Template Reference

\inmodule QtCore More...

#include <qatomic.h>

Inheritance diagram for QAtomicInteger< T >:
Collaboration diagram for QAtomicInteger< T >:

Public Member Functions

constexpr QAtomicInteger (T value=0) noexcept
 Constructs a QAtomicInteger with the given value.
 QAtomicInteger (const QAtomicInteger &other) noexcept
 Constructs a copy of other.
QAtomicIntegeroperator= (const QAtomicInteger &other) noexcept
 Assigns other to this QAtomicInteger and returns a reference to this QAtomicInteger.
Public Member Functions inherited from QBasicAtomicInteger< T >
loadRelaxed () const noexcept
void storeRelaxed (T newValue) noexcept
loadAcquire () const noexcept
void storeRelease (T newValue) noexcept
 operator T () const noexcept
operator= (T newValue) noexcept
bool ref () noexcept
bool deref () noexcept
bool testAndSetRelaxed (T expectedValue, T newValue) noexcept
bool testAndSetAcquire (T expectedValue, T newValue) noexcept
bool testAndSetRelease (T expectedValue, T newValue) noexcept
bool testAndSetOrdered (T expectedValue, T newValue) noexcept
bool testAndSetRelaxed (T expectedValue, T newValue, T &currentValue) noexcept
bool testAndSetAcquire (T expectedValue, T newValue, T &currentValue) noexcept
bool testAndSetRelease (T expectedValue, T newValue, T &currentValue) noexcept
bool testAndSetOrdered (T expectedValue, T newValue, T &currentValue) noexcept
fetchAndStoreRelaxed (T newValue) noexcept
fetchAndStoreAcquire (T newValue) noexcept
fetchAndStoreRelease (T newValue) noexcept
fetchAndStoreOrdered (T newValue) noexcept
fetchAndAddRelaxed (T valueToAdd) noexcept
fetchAndAddAcquire (T valueToAdd) noexcept
fetchAndAddRelease (T valueToAdd) noexcept
fetchAndAddOrdered (T valueToAdd) noexcept
fetchAndSubRelaxed (T valueToAdd) noexcept
fetchAndSubAcquire (T valueToAdd) noexcept
fetchAndSubRelease (T valueToAdd) noexcept
fetchAndSubOrdered (T valueToAdd) noexcept
fetchAndAndRelaxed (T valueToAdd) noexcept
fetchAndAndAcquire (T valueToAdd) noexcept
fetchAndAndRelease (T valueToAdd) noexcept
fetchAndAndOrdered (T valueToAdd) noexcept
fetchAndOrRelaxed (T valueToAdd) noexcept
fetchAndOrAcquire (T valueToAdd) noexcept
fetchAndOrRelease (T valueToAdd) noexcept
fetchAndOrOrdered (T valueToAdd) noexcept
fetchAndXorRelaxed (T valueToAdd) noexcept
fetchAndXorAcquire (T valueToAdd) noexcept
fetchAndXorRelease (T valueToAdd) noexcept
fetchAndXorOrdered (T valueToAdd) noexcept
operator++ () noexcept
operator++ (int) noexcept
operator-- () noexcept
operator-- (int) noexcept
operator+= (T v) noexcept
operator-= (T v) noexcept
operator&= (T v) noexcept
operator|= (T v) noexcept
operator^= (T v) noexcept
 QBasicAtomicInteger ()=default
constexpr QBasicAtomicInteger (T value) noexcept
 QBasicAtomicInteger (const QBasicAtomicInteger &)=delete
QBasicAtomicIntegeroperator= (const QBasicAtomicInteger &)=delete
QBasicAtomicIntegeroperator= (const QBasicAtomicInteger &) volatile =delete

Additional Inherited Members

Public Types inherited from QBasicAtomicInteger< T >
typedef T Type
typedef QAtomicOps< T > Ops
Static Public Member Functions inherited from QBasicAtomicInteger< T >
static constexpr bool isReferenceCountingNative () noexcept
static constexpr bool isReferenceCountingWaitFree () noexcept
static constexpr bool isTestAndSetNative () noexcept
static constexpr bool isTestAndSetWaitFree () noexcept
static constexpr bool isFetchAndStoreNative () noexcept
static constexpr bool isFetchAndStoreWaitFree () noexcept
static constexpr bool isFetchAndAddNative () noexcept
static constexpr bool isFetchAndAddWaitFree () noexcept
Public Attributes inherited from QBasicAtomicInteger< T >
Ops::Type _q_value

Detailed Description

template<typename T>
class QAtomicInteger< T >

\inmodule QtCore

The QAtomicInteger class provides platform-independent atomic operations on integers.

Since
5.3

For atomic operations on pointers, see the QAtomicPointer class.

An atomic operation is a complex operation that completes without interruption. The QAtomicInteger class provides atomic reference counting, test-and-set, fetch-and-store, and fetch-and-add for integers.

The template parameter T must be a C++ integer type: \list

  • 8-bit: bool, char, signed char, unsigned char, qint8, quint8, char8_t (C++20)
  • 16-bit: short, unsigned short, qint16, quint16, char16_t
  • 32-bit: int, unsigned int, qint32, quint32, char32_t
  • 64-bit: long long, unsigned long long, qint64, quint64
  • platform-specific size: long, unsigned long
  • pointer size: qintptr, quintptr, qptrdiff \endlist

Of the list above, only the 8-bit, 16-bit, 32-bit- and pointer-sized instantiations are guaranteed to work on all platforms. Support for other sizes depends on the compiler and processor architecture the code is being compiled for. To test whether the 64-bit types are supported on 32-bit platforms, check the macro Q_ATOMIC_INT64_IS_SUPPORTED.

Definition at line 18 of file qatomic.h.

Constructor & Destructor Documentation

◆ QAtomicInteger() [1/2]

template<typename T>
QAtomicInteger< T >::QAtomicInteger ( T value = 0)
inlineconstexprnoexcept

Constructs a QAtomicInteger with the given value.

Definition at line 22 of file qatomic.h.

◆ QAtomicInteger() [2/2]

template<typename T>
QAtomicInteger< T >::QAtomicInteger ( const QAtomicInteger< T > & other)
inlinenoexcept

Constructs a copy of other.

Definition at line 24 of file qatomic.h.

Member Function Documentation

◆ operator=()

template<typename T>
QAtomicInteger & QAtomicInteger< T >::operator= ( const QAtomicInteger< T > & other)
inlinenoexcept

Assigns other to this QAtomicInteger and returns a reference to this QAtomicInteger.

Since
5.3

Atomically stores the other value into this atomic type using a sequentially consistent memory ordering if possible; or "Release" ordering if not. This function returns a reference to this object.

See also
storeRelaxed(), storeRelease()

Definition at line 30 of file qatomic.h.


The documentation for this class was generated from the following files: