diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-24 15:46:26 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-06-25 21:06:19 +0000 |
commit | c060f6e765a2f155b38158f2ed73eac4aad37e02 (patch) | |
tree | 2cb7b1d9752b607bd4f55d4f14a4e6d5aa094e34 | |
parent | b1f238568214e6587b829d6695677e55a99b1d40 (diff) |
Port towards load/storeRelaxed atomics
Plain load() / store() have been deprecated, so port away
to their straight replacements.
Task-number: QTBUG-76611
Change-Id: I79935b889cf7b2ba7698f70cc5e33994b034aa09
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
-rw-r--r-- | src/qml/jsruntime/qv4identifier.cpp | 4 | ||||
-rw-r--r-- | src/qml/memory/qv4heap_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/ftw/qqmlrefcount_p.h | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlnotifier.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmltypemodule.cpp | 16 |
7 files changed, 25 insertions, 25 deletions
diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp index f9bc7b68c6..49981ecaed 100644 --- a/src/qml/jsruntime/qv4identifier.cpp +++ b/src/qml/jsruntime/qv4identifier.cpp @@ -50,7 +50,7 @@ IdentifierHashData::IdentifierHashData(IdentifierTable *table, int numBits) , numBits(numBits) , identifierTable(table) { - refCount.store(1); + refCount.storeRelaxed(1); alloc = qPrimeForNumBits(numBits); entries = (IdentifierHashEntry *)malloc(alloc*sizeof(IdentifierHashEntry)); memset(entries, 0, alloc*sizeof(IdentifierHashEntry)); @@ -62,7 +62,7 @@ IdentifierHashData::IdentifierHashData(IdentifierHashData *other) , numBits(other->numBits) , identifierTable(other->identifierTable) { - refCount.store(1); + refCount.storeRelaxed(1); alloc = other->alloc; entries = (IdentifierHashEntry *)malloc(alloc*sizeof(IdentifierHashEntry)); memcpy(entries, other->entries, alloc*sizeof(IdentifierHashEntry)); diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h index 07af5a6f7a..d7cfa193e6 100644 --- a/src/qml/memory/qv4heap_p.h +++ b/src/qml/memory/qv4heap_p.h @@ -234,7 +234,7 @@ struct QQmlQPointer { } T *data() const { - return d == nullptr || d->strongref.load() == 0 ? nullptr : qObject; + return d == nullptr || d->strongref.loadRelaxed() == 0 ? nullptr : qObject; } operator T*() const { return data(); } inline T* operator->() const { return data(); } @@ -247,7 +247,7 @@ struct QQmlQPointer { } bool isNull() const Q_DECL_NOTHROW { - return d == nullptr || qObject == nullptr || d->strongref.load() == 0; + return d == nullptr || qObject == nullptr || d->strongref.loadRelaxed() == 0; } private: diff --git a/src/qml/qml/ftw/qqmlrefcount_p.h b/src/qml/qml/ftw/qqmlrefcount_p.h index 140f129b21..b4f8acad49 100644 --- a/src/qml/qml/ftw/qqmlrefcount_p.h +++ b/src/qml/qml/ftw/qqmlrefcount_p.h @@ -113,25 +113,25 @@ QQmlRefCount::QQmlRefCount() QQmlRefCount::~QQmlRefCount() { - Q_ASSERT(refCount.load() == 0); + Q_ASSERT(refCount.loadRelaxed() == 0); } void QQmlRefCount::addref() const { - Q_ASSERT(refCount.load() > 0); + Q_ASSERT(refCount.loadRelaxed() > 0); refCount.ref(); } void QQmlRefCount::release() const { - Q_ASSERT(refCount.load() > 0); + Q_ASSERT(refCount.loadRelaxed() > 0); if (!refCount.deref()) delete this; } int QQmlRefCount::count() const { - return refCount.load(); + return refCount.loadRelaxed(); } template<class T> diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5e06ff283e..860c24541e 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -811,7 +811,7 @@ void QQmlData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int in // marshalled back onto the QObject's thread and handled by QML from there. This is tested // by the qqmlecmascript::threadSignal() autotest. if (ddata->notifyList && - QThread::currentThreadId() != QObjectPrivate::get(object)->threadData->threadId.load()) { + QThread::currentThreadId() != QObjectPrivate::get(object)->threadData->threadId.loadRelaxed()) { if (!QObjectPrivate::get(object)->threadData->thread) return; diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp index 0706b8c0cf..1359586b31 100644 --- a/src/qml/qml/qqmlnotifier.cpp +++ b/src/qml/qml/qqmlnotifier.cpp @@ -118,8 +118,8 @@ void QQmlNotifierEndpoint::connect(QObject *source, int sourceSignal, QQmlEngine disconnect(); Q_ASSERT(engine); - if (QObjectPrivate::get(source)->threadData->threadId.load() != - QObjectPrivate::get(engine)->threadData->threadId.load()) { + if (QObjectPrivate::get(source)->threadData->threadId.loadRelaxed() != + QObjectPrivate::get(engine)->threadData->threadId.loadRelaxed()) { QString sourceName; QDebug(&sourceName) << source; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 15a9c30c28..0bfdbdd2fa 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -756,13 +756,13 @@ QQmlDataBlob::ThreadData::ThreadData() QQmlDataBlob::Status QQmlDataBlob::ThreadData::status() const { - return QQmlDataBlob::Status((_p.load() & TD_STATUS_MASK) >> TD_STATUS_SHIFT); + return QQmlDataBlob::Status((_p.loadRelaxed() & TD_STATUS_MASK) >> TD_STATUS_SHIFT); } void QQmlDataBlob::ThreadData::setStatus(QQmlDataBlob::Status status) { while (true) { - int d = _p.load(); + int d = _p.loadRelaxed(); int nd = (d & ~TD_STATUS_MASK) | ((status << TD_STATUS_SHIFT) & TD_STATUS_MASK); if (d == nd || _p.testAndSetOrdered(d, nd)) return; } @@ -770,13 +770,13 @@ void QQmlDataBlob::ThreadData::setStatus(QQmlDataBlob::Status status) bool QQmlDataBlob::ThreadData::isAsync() const { - return _p.load() & TD_ASYNC_MASK; + return _p.loadRelaxed() & TD_ASYNC_MASK; } void QQmlDataBlob::ThreadData::setIsAsync(bool v) { while (true) { - int d = _p.load(); + int d = _p.loadRelaxed(); int nd = (d & ~TD_ASYNC_MASK) | (v?TD_ASYNC_MASK:0); if (d == nd || _p.testAndSetOrdered(d, nd)) return; } @@ -784,13 +784,13 @@ void QQmlDataBlob::ThreadData::setIsAsync(bool v) quint8 QQmlDataBlob::ThreadData::progress() const { - return quint8((_p.load() & TD_PROGRESS_MASK) >> TD_PROGRESS_SHIFT); + return quint8((_p.loadRelaxed() & TD_PROGRESS_MASK) >> TD_PROGRESS_SHIFT); } void QQmlDataBlob::ThreadData::setProgress(quint8 v) { while (true) { - int d = _p.load(); + int d = _p.loadRelaxed(); int nd = (d & ~TD_PROGRESS_MASK) | ((v << TD_PROGRESS_SHIFT) & TD_PROGRESS_MASK); if (d == nd || _p.testAndSetOrdered(d, nd)) return; } diff --git a/src/qml/qml/qqmltypemodule.cpp b/src/qml/qml/qqmltypemodule.cpp index 4d7553fbab..9c9bf3e48f 100644 --- a/src/qml/qml/qqmltypemodule.cpp +++ b/src/qml/qml/qqmltypemodule.cpp @@ -69,24 +69,24 @@ int QQmlTypeModule::majorVersion() const int QQmlTypeModule::minimumMinorVersion() const { - return d->minMinorVersion.load(); + return d->minMinorVersion.loadRelaxed(); } int QQmlTypeModule::maximumMinorVersion() const { - return d->maxMinorVersion.load(); + return d->maxMinorVersion.loadRelaxed(); } void QQmlTypeModule::addMinorVersion(int version) { - for (int oldVersion = d->minMinorVersion.load(); + for (int oldVersion = d->minMinorVersion.loadRelaxed(); oldVersion > version && !d->minMinorVersion.testAndSetOrdered(oldVersion, version); - oldVersion = d->minMinorVersion.load()) { + oldVersion = d->minMinorVersion.loadRelaxed()) { } - for (int oldVersion = d->maxMinorVersion.load(); + for (int oldVersion = d->maxMinorVersion.loadRelaxed(); oldVersion < version && !d->maxMinorVersion.testAndSetOrdered(oldVersion, version); - oldVersion = d->maxMinorVersion.load()) { + oldVersion = d->maxMinorVersion.loadRelaxed()) { } } @@ -125,12 +125,12 @@ void QQmlTypeModule::remove(const QQmlTypePrivate *type) bool QQmlTypeModule::isLocked() const { - return d->locked.load() != 0; + return d->locked.loadRelaxed() != 0; } void QQmlTypeModule::lock() { - d->locked.store(1); + d->locked.storeRelaxed(1); } QQmlType QQmlTypeModule::type(const QHashedStringRef &name, int minor) const |