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
27 static T add_no_UB(T lhs, T rhs)
29 using U = std::make_unsigned_t<T>;
30 return T(U(lhs) + U(rhs));
32 static T sub_no_UB(T lhs, T rhs)
34 using U = std::make_unsigned_t<T>;
35 return T(U(lhs) - U(rhs));
39 typedef QAtomicOps<T> Ops;
41 static_assert(std::is_integral_v<T>,
"template parameter is not an integral type");
42 static_assert(QAtomicOpsSupport<
sizeof(T)>::IsSupported,
"template parameter is an integral of a size not supported on this platform");
44 typename Ops::Type _q_value;
48 T loadRelaxed()
const noexcept {
return Ops::loadRelaxed(_q_value); }
49 void storeRelaxed(T newValue)
noexcept { Ops::storeRelaxed(_q_value, newValue); }
51 T loadAcquire()
const noexcept {
return Ops::loadAcquire(_q_value); }
52 void storeRelease(T newValue)
noexcept { Ops::storeRelease(_q_value, newValue); }
53 operator T()
const noexcept {
return loadAcquire(); }
54 T operator=(T newValue)
noexcept { storeRelease(newValue);
return newValue; }
56 static constexpr bool isReferenceCountingNative()
noexcept {
return Ops::isReferenceCountingNative(); }
57 static constexpr bool isReferenceCountingWaitFree()
noexcept {
return Ops::isReferenceCountingWaitFree(); }
59 bool ref()
noexcept {
return Ops::ref(_q_value); }
60 void refRelaxed()
noexcept { Ops::fetchAndAddRelaxed(_q_value, 1); }
61 bool deref()
noexcept {
return Ops::deref(_q_value); }
63 static constexpr bool isTestAndSetNative()
noexcept {
return Ops::isTestAndSetNative(); }
64 static constexpr bool isTestAndSetWaitFree()
noexcept {
return Ops::isTestAndSetWaitFree(); }
66 bool testAndSetRelaxed(T expectedValue, T newValue)
noexcept
67 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); }
68 bool testAndSetAcquire(T expectedValue, T newValue)
noexcept
69 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); }
70 bool testAndSetRelease(T expectedValue, T newValue)
noexcept
71 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue); }
72 bool testAndSetOrdered(T expectedValue, T newValue)
noexcept
73 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); }
75 bool testAndSetRelaxed(T expectedValue, T newValue, T ¤tValue)
noexcept
76 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); }
77 bool testAndSetAcquire(T expectedValue, T newValue, T ¤tValue)
noexcept
78 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); }
79 bool testAndSetRelease(T expectedValue, T newValue, T ¤tValue)
noexcept
80 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); }
81 bool testAndSetOrdered(T expectedValue, T newValue, T ¤tValue)
noexcept
82 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); }
84 static constexpr bool isFetchAndStoreNative()
noexcept {
return Ops::isFetchAndStoreNative(); }
85 static constexpr bool isFetchAndStoreWaitFree()
noexcept {
return Ops::isFetchAndStoreWaitFree(); }
87 T fetchAndStoreRelaxed(T newValue)
noexcept
88 {
return Ops::fetchAndStoreRelaxed(_q_value, newValue); }
89 T fetchAndStoreAcquire(T newValue)
noexcept
90 {
return Ops::fetchAndStoreAcquire(_q_value, newValue); }
91 T fetchAndStoreRelease(T newValue)
noexcept
92 {
return Ops::fetchAndStoreRelease(_q_value, newValue); }
93 T fetchAndStoreOrdered(T newValue)
noexcept
94 {
return Ops::fetchAndStoreOrdered(_q_value, newValue); }
96 static constexpr bool isFetchAndAddNative()
noexcept {
return Ops::isFetchAndAddNative(); }
97 static constexpr bool isFetchAndAddWaitFree()
noexcept {
return Ops::isFetchAndAddWaitFree(); }
99 T fetchAndAddRelaxed(T valueToAdd)
noexcept
100 {
return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); }
101 T fetchAndAddAcquire(T valueToAdd)
noexcept
102 {
return Ops::fetchAndAddAcquire(_q_value, valueToAdd); }
103 T fetchAndAddRelease(T valueToAdd)
noexcept
104 {
return Ops::fetchAndAddRelease(_q_value, valueToAdd); }
105 T fetchAndAddOrdered(T valueToAdd)
noexcept
106 {
return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
108 T fetchAndSubRelaxed(T valueToAdd)
noexcept
109 {
return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); }
110 T fetchAndSubAcquire(T valueToAdd)
noexcept
111 {
return Ops::fetchAndSubAcquire(_q_value, valueToAdd); }
112 T fetchAndSubRelease(T valueToAdd)
noexcept
113 {
return Ops::fetchAndSubRelease(_q_value, valueToAdd); }
114 T fetchAndSubOrdered(T valueToAdd)
noexcept
115 {
return Ops::fetchAndSubOrdered(_q_value, valueToAdd); }
117 T fetchAndAndRelaxed(T valueToAdd)
noexcept
118 {
return Ops::fetchAndAndRelaxed(_q_value, valueToAdd); }
119 T fetchAndAndAcquire(T valueToAdd)
noexcept
120 {
return Ops::fetchAndAndAcquire(_q_value, valueToAdd); }
121 T fetchAndAndRelease(T valueToAdd)
noexcept
122 {
return Ops::fetchAndAndRelease(_q_value, valueToAdd); }
123 T fetchAndAndOrdered(T valueToAdd)
noexcept
124 {
return Ops::fetchAndAndOrdered(_q_value, valueToAdd); }
126 T fetchAndOrRelaxed(T valueToAdd)
noexcept
127 {
return Ops::fetchAndOrRelaxed(_q_value, valueToAdd); }
128 T fetchAndOrAcquire(T valueToAdd)
noexcept
129 {
return Ops::fetchAndOrAcquire(_q_value, valueToAdd); }
130 T fetchAndOrRelease(T valueToAdd)
noexcept
131 {
return Ops::fetchAndOrRelease(_q_value, valueToAdd); }
132 T fetchAndOrOrdered(T valueToAdd)
noexcept
133 {
return Ops::fetchAndOrOrdered(_q_value, valueToAdd); }
135 T fetchAndXorRelaxed(T valueToAdd)
noexcept
136 {
return Ops::fetchAndXorRelaxed(_q_value, valueToAdd); }
137 T fetchAndXorAcquire(T valueToAdd)
noexcept
138 {
return Ops::fetchAndXorAcquire(_q_value, valueToAdd); }
139 T fetchAndXorRelease(T valueToAdd)
noexcept
140 {
return Ops::fetchAndXorRelease(_q_value, valueToAdd); }
141 T fetchAndXorOrdered(T valueToAdd)
noexcept
142 {
return Ops::fetchAndXorOrdered(_q_value, valueToAdd); }
144 T operator++()
noexcept
145 {
return add_no_UB(fetchAndAddOrdered(1), 1); }
146 T operator++(
int)
noexcept
147 {
return fetchAndAddOrdered(1); }
148 T operator--()
noexcept
149 {
return sub_no_UB(fetchAndSubOrdered(1), 1); }
150 T operator--(
int)
noexcept
151 {
return fetchAndSubOrdered(1); }
153 T operator+=(T v)
noexcept
154 {
return add_no_UB(fetchAndAddOrdered(v), v); }
155 T operator-=(T v)
noexcept
156 {
return sub_no_UB(fetchAndSubOrdered(v), v); }
157 T operator&=(T v)
noexcept
158 {
return fetchAndAndOrdered(v) & v; }
159 T operator|=(T v)
noexcept
160 {
return fetchAndOrOrdered(v) | v; }
161 T operator^=(T v)
noexcept
162 {
return fetchAndXorOrdered(v) ^ v; }
165 QBasicAtomicInteger() =
default;
166 constexpr QBasicAtomicInteger(T value)
noexcept : _q_value(value) {}
167 QBasicAtomicInteger(
const QBasicAtomicInteger &) =
delete;
168 QBasicAtomicInteger &operator=(
const QBasicAtomicInteger &) =
delete;
169 QBasicAtomicInteger &operator=(
const QBasicAtomicInteger &)
volatile =
delete;
197 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); }
199 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); }
201 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue); }
203 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); }
206 {
return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); }
208 {
return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); }
210 {
return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); }
212 {
return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); }
218 {
return Ops::fetchAndStoreRelaxed(_q_value, newValue); }
220 {
return Ops::fetchAndStoreAcquire(_q_value, newValue); }
222 {
return Ops::fetchAndStoreRelease(_q_value, newValue); }
224 {
return Ops::fetchAndStoreOrdered(_q_value, newValue); }
230 {
return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); }
232 {
return Ops::fetchAndAddAcquire(_q_value, valueToAdd); }
234 {
return Ops::fetchAndAddRelease(_q_value, valueToAdd); }
236 {
return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
239 {
return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); }
241 {
return Ops::fetchAndSubAcquire(_q_value, valueToAdd); }
243 {
return Ops::fetchAndSubRelease(_q_value, valueToAdd); }
245 {
return Ops::fetchAndSubOrdered(_q_value, valueToAdd); }
248 {
return fetchAndAddOrdered(1) + 1; }
250 {
return fetchAndAddOrdered(1); }
252 {
return fetchAndSubOrdered(1) - 1; }
254 {
return fetchAndSubOrdered(1); }
256 {
return fetchAndAddOrdered(valueToAdd) + valueToAdd; }
258 {
return fetchAndSubOrdered(valueToSub) - valueToSub; }
267#ifndef Q_BASIC_ATOMIC_INITIALIZER
268# 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.
QDisconnectNotifyEvent(int signalIndex)
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)