make QAtomicInt reference counting logic match that of QBasicAtomicInt

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2019-05-18 04:53:22 +00:00
parent 4bf04ce267
commit ac5452a085

View file

@ -85,17 +85,15 @@ class Q_CORE_EXPORT QAtomicInt
}
bool ref() {
int newValue = ++m_data;
return newValue != 0;
return fetchAndAddOrdered(1) != -1;
}
bool deref() {
int newValue = --m_data;
return newValue != 0;
return fetchAndAddOrdered(-1) != 1;
}
bool testAndSetRelaxed(int expectedValue, int newValue) {
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
return m_data.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
}
bool testAndSetAcquire(int expectedValue, int newValue) {