9#include <QtCore/qatomic_cxx11.h>
12QT_WARNING_DISABLE_MSVC(4522)
19#pragma qt_no_master_include
20#pragma qt_sync_stop_processing
24class QBasicAtomicInteger
28 typedef QAtomicOps<T> Ops;
30 static_assert(std::is_integral_v<T>,
"template parameter is not an integral type");
31 static_assert(QAtomicOpsSupport<
sizeof(T)>::IsSupported,
"template parameter is an integral of a size not supported on this platform");
33 typename Ops::Type _q_value;
37 T loadRelaxed()
const noexcept {
return Ops::loadRelaxed(_q_value); }
38 void storeRelaxed(T newValue)
noexcept { Ops::storeRelaxed(_q_value, newValue); }
40 T loadAcquire()
const noexcept {
return Ops::loadAcquire(_q_value); }
41 void storeRelease(T newValue)
noexcept { Ops::storeRelease(_q_value, newValue); }
42 operator T()
const noexcept {
return loadAcquire(); }
43 T operator=(T newValue)
noexcept { storeRelease(newValue);
return newValue; }
45 static constexpr bool isReferenceCountingNative()
noexcept {
return Ops::isReferenceCountingNative(); }
46 static constexpr bool isReferenceCountingWaitFree()
noexcept {
return Ops::isReferenceCountingWaitFree(); }
48 bool ref()
noexcept {
return Ops::ref(_q_value); }
49 void refRelaxed()
noexcept { Ops::fetchAndAddRelaxed(_q_value, 1); }
50 bool deref()
noexcept {
return Ops::deref(_q_value); }
52 static constexpr bool isTestAndSetNative()
noexcept {
return Ops::isTestAndSetNative(); }
53 static constexpr bool isTestAndSetWaitFree()
noexcept {
return Ops::isTestAndSetWaitFree(); }
55 bool testAndSetRelaxed(T expectedValue, T newValue)
noexcept
56 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); }
57 bool testAndSetAcquire(T expectedValue, T newValue)
noexcept
58 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); }
59 bool testAndSetRelease(T expectedValue, T newValue)
noexcept
60 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue); }
61 bool testAndSetOrdered(T expectedValue, T newValue)
noexcept
62 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); }
64 bool testAndSetRelaxed(T expectedValue, T newValue, T ¤tValue)
noexcept
65 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); }
66 bool testAndSetAcquire(T expectedValue, T newValue, T ¤tValue)
noexcept
67 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); }
68 bool testAndSetRelease(T expectedValue, T newValue, T ¤tValue)
noexcept
69 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); }
70 bool testAndSetOrdered(T expectedValue, T newValue, T ¤tValue)
noexcept
71 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); }
73 static constexpr bool isFetchAndStoreNative()
noexcept {
return Ops::isFetchAndStoreNative(); }
74 static constexpr bool isFetchAndStoreWaitFree()
noexcept {
return Ops::isFetchAndStoreWaitFree(); }
76 T fetchAndStoreRelaxed(T newValue)
noexcept
77 {
return Ops::fetchAndStoreRelaxed(_q_value, newValue); }
78 T fetchAndStoreAcquire(T newValue)
noexcept
79 {
return Ops::fetchAndStoreAcquire(_q_value, newValue); }
80 T fetchAndStoreRelease(T newValue)
noexcept
81 {
return Ops::fetchAndStoreRelease(_q_value, newValue); }
82 T fetchAndStoreOrdered(T newValue)
noexcept
83 {
return Ops::fetchAndStoreOrdered(_q_value, newValue); }
85 static constexpr bool isFetchAndAddNative()
noexcept {
return Ops::isFetchAndAddNative(); }
86 static constexpr bool isFetchAndAddWaitFree()
noexcept {
return Ops::isFetchAndAddWaitFree(); }
88 T fetchAndAddRelaxed(T valueToAdd)
noexcept
89 {
return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); }
90 T fetchAndAddAcquire(T valueToAdd)
noexcept
91 {
return Ops::fetchAndAddAcquire(_q_value, valueToAdd); }
92 T fetchAndAddRelease(T valueToAdd)
noexcept
93 {
return Ops::fetchAndAddRelease(_q_value, valueToAdd); }
94 T fetchAndAddOrdered(T valueToAdd)
noexcept
95 {
return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
97 T fetchAndSubRelaxed(T valueToAdd)
noexcept
98 {
return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); }
99 T fetchAndSubAcquire(T valueToAdd)
noexcept
100 {
return Ops::fetchAndSubAcquire(_q_value, valueToAdd); }
101 T fetchAndSubRelease(T valueToAdd)
noexcept
102 {
return Ops::fetchAndSubRelease(_q_value, valueToAdd); }
103 T fetchAndSubOrdered(T valueToAdd)
noexcept
104 {
return Ops::fetchAndSubOrdered(_q_value, valueToAdd); }
106 T fetchAndAndRelaxed(T valueToAdd)
noexcept
107 {
return Ops::fetchAndAndRelaxed(_q_value, valueToAdd); }
108 T fetchAndAndAcquire(T valueToAdd)
noexcept
109 {
return Ops::fetchAndAndAcquire(_q_value, valueToAdd); }
110 T fetchAndAndRelease(T valueToAdd)
noexcept
111 {
return Ops::fetchAndAndRelease(_q_value, valueToAdd); }
112 T fetchAndAndOrdered(T valueToAdd)
noexcept
113 {
return Ops::fetchAndAndOrdered(_q_value, valueToAdd); }
115 T fetchAndOrRelaxed(T valueToAdd)
noexcept
116 {
return Ops::fetchAndOrRelaxed(_q_value, valueToAdd); }
117 T fetchAndOrAcquire(T valueToAdd)
noexcept
118 {
return Ops::fetchAndOrAcquire(_q_value, valueToAdd); }
119 T fetchAndOrRelease(T valueToAdd)
noexcept
120 {
return Ops::fetchAndOrRelease(_q_value, valueToAdd); }
121 T fetchAndOrOrdered(T valueToAdd)
noexcept
122 {
return Ops::fetchAndOrOrdered(_q_value, valueToAdd); }
124 T fetchAndXorRelaxed(T valueToAdd)
noexcept
125 {
return Ops::fetchAndXorRelaxed(_q_value, valueToAdd); }
126 T fetchAndXorAcquire(T valueToAdd)
noexcept
127 {
return Ops::fetchAndXorAcquire(_q_value, valueToAdd); }
128 T fetchAndXorRelease(T valueToAdd)
noexcept
129 {
return Ops::fetchAndXorRelease(_q_value, valueToAdd); }
130 T fetchAndXorOrdered(T valueToAdd)
noexcept
131 {
return Ops::fetchAndXorOrdered(_q_value, valueToAdd); }
133 T operator++()
noexcept
134 {
return fetchAndAddOrdered(1) + 1; }
135 T operator++(
int)
noexcept
136 {
return fetchAndAddOrdered(1); }
137 T operator--()
noexcept
138 {
return fetchAndSubOrdered(1) - 1; }
139 T operator--(
int)
noexcept
140 {
return fetchAndSubOrdered(1); }
142 T operator+=(T v)
noexcept
143 {
return fetchAndAddOrdered(v) + v; }
144 T operator-=(T v)
noexcept
145 {
return fetchAndSubOrdered(v) - v; }
146 T operator&=(T v)
noexcept
147 {
return fetchAndAndOrdered(v) & v; }
148 T operator|=(T v)
noexcept
149 {
return fetchAndOrOrdered(v) | v; }
150 T operator^=(T v)
noexcept
151 {
return fetchAndXorOrdered(v) ^ v; }
154 QBasicAtomicInteger() =
default;
155 constexpr QBasicAtomicInteger(T value)
noexcept : _q_value(value) {}
156 QBasicAtomicInteger(
const QBasicAtomicInteger &) =
delete;
157 QBasicAtomicInteger &operator=(
const QBasicAtomicInteger &) =
delete;
158 QBasicAtomicInteger &operator=(
const QBasicAtomicInteger &)
volatile =
delete;
186 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); }
188 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); }
190 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue); }
192 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); }
195 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); }
197 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); }
199 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); }
201 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); }
207 {
return Ops::fetchAndStoreRelaxed(_q_value, newValue); }
209 {
return Ops::fetchAndStoreAcquire(_q_value, newValue); }
211 {
return Ops::fetchAndStoreRelease(_q_value, newValue); }
213 {
return Ops::fetchAndStoreOrdered(_q_value, newValue); }
219 {
return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); }
221 {
return Ops::fetchAndAddAcquire(_q_value, valueToAdd); }
223 {
return Ops::fetchAndAddRelease(_q_value, valueToAdd); }
225 {
return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
228 {
return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); }
230 {
return Ops::fetchAndSubAcquire(_q_value, valueToAdd); }
232 {
return Ops::fetchAndSubRelease(_q_value, valueToAdd); }
234 {
return Ops::fetchAndSubOrdered(_q_value, valueToAdd); }
237 {
return fetchAndAddOrdered(1) + 1; }
239 {
return fetchAndAddOrdered(1); }
241 {
return fetchAndSubOrdered(1) - 1; }
243 {
return fetchAndSubOrdered(1); }
245 {
return fetchAndAddOrdered(valueToAdd) + valueToAdd; }
247 {
return fetchAndSubOrdered(valueToSub) - valueToSub; }
256#ifndef Q_BASIC_ATOMIC_INITIALIZER
257# define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) }
bool testAndSetOrdered(Type expectedValue, Type newValue, Type ¤tValue) noexcept
QBasicAtomicPointer & operator=(const QBasicAtomicPointer &)=delete
Type fetchAndAddOrdered(qptrdiff valueToAdd) noexcept
bool testAndSetRelaxed(Type expectedValue, Type newValue) noexcept
Type fetchAndStoreAcquire(Type newValue) noexcept
Type fetchAndStoreRelease(Type newValue) noexcept
Type operator-=(qptrdiff valueToSub) noexcept
static constexpr bool isFetchAndAddNative() noexcept
bool testAndSetRelease(Type expectedValue, Type newValue) noexcept
Type fetchAndStoreOrdered(Type newValue) noexcept
QBasicAtomicPointer()=default
Type operator=(Type newValue) noexcept
constexpr QBasicAtomicPointer(Type value) noexcept
bool testAndSetAcquire(Type expectedValue, Type newValue) noexcept
bool testAndSetRelease(Type expectedValue, Type newValue, Type ¤tValue) noexcept
Type operator++(int) noexcept
QBasicAtomicPointer(const QBasicAtomicPointer &)=delete
Type loadAcquire() const noexcept
Type operator--(int) noexcept
bool testAndSetAcquire(Type expectedValue, Type newValue, Type ¤tValue) noexcept
Type fetchAndSubRelaxed(qptrdiff valueToAdd) noexcept
static constexpr bool isFetchAndAddWaitFree() noexcept
bool testAndSetOrdered(Type expectedValue, Type newValue) noexcept
static constexpr bool isTestAndSetNative() noexcept
Type operator+=(qptrdiff valueToAdd) noexcept
Type fetchAndSubOrdered(qptrdiff valueToAdd) noexcept
Type loadRelaxed() const noexcept
Type operator++() noexcept
static constexpr bool isFetchAndStoreWaitFree() noexcept
Type fetchAndSubRelease(qptrdiff valueToAdd) noexcept
QBasicAtomicPointer & operator=(const QBasicAtomicPointer &) volatile =delete
void storeRelaxed(Type newValue) noexcept
bool testAndSetRelaxed(Type expectedValue, Type newValue, Type ¤tValue) noexcept
Type fetchAndAddRelaxed(qptrdiff valueToAdd) noexcept
void storeRelease(Type newValue) noexcept
operator Type() const noexcept
Type fetchAndSubAcquire(qptrdiff valueToAdd) noexcept
Type fetchAndAddRelease(qptrdiff valueToAdd) noexcept
static constexpr bool isTestAndSetWaitFree() noexcept
Type fetchAndAddAcquire(qptrdiff valueToAdd) noexcept
Type operator--() noexcept
Type fetchAndStoreRelaxed(Type newValue) noexcept
static constexpr bool isFetchAndStoreNative() noexcept
QDeferredDeleteEvent(int loopLevel, int scopeLevel)
Constructs a deferred delete event with the given loop and scope level.
QBasicAtomicInteger< int > QBasicAtomicInt
static int registerEventTypeZeroBased(int id) noexcept
QBasicAtomicBitField< QEvent::MaxUser - QEvent::User+1 > UserEventTypeRegistry
QT_BEGIN_NAMESPACE Q_TRACE_POINT(qtcore, QEvent_ctor, QEvent *event, QEvent::Type type)
#define Q_IMPL_EVENT_COMMON(Class)