diff options
Diffstat (limited to 'src/corelib/tools/qfreelist_p.h')
-rw-r--r-- | src/corelib/tools/qfreelist_p.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index 7776dd8c4e..5ba23b344b 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -171,7 +171,7 @@ class QFreeList // qDebug("QFreeList: allocating %d elements (%ld bytes) with offset %d", size, size * sizeof(ElementType), offset); ElementType *v = new ElementType[size]; for (int i = 0; i < size; ++i) - v[i].next.store(offset + i + 1); + v[i].next.storeRelaxed(offset + i + 1); return v; } @@ -225,14 +225,14 @@ template <typename T, typename ConstantsType> inline typename QFreeList<T, ConstantsType>::ConstReferenceType QFreeList<T, ConstantsType>::at(int x) const { const int block = blockfor(x); - return (_v[block].load())[x].t(); + return (_v[block].loadRelaxed())[x].t(); } template <typename T, typename ConstantsType> inline typename QFreeList<T, ConstantsType>::ReferenceType QFreeList<T, ConstantsType>::operator[](int x) { const int block = blockfor(x); - return (_v[block].load())[x].t(); + return (_v[block].loadRelaxed())[x].t(); } template <typename T, typename ConstantsType> @@ -249,15 +249,15 @@ inline int QFreeList<T, ConstantsType>::next() if (!v) { v = allocate((id & ConstantsType::IndexMask) - at, ConstantsType::Sizes[block]); - if (!_v[block].testAndSetRelease(0, v)) { + if (!_v[block].testAndSetRelease(nullptr, v)) { // race with another thread lost delete [] v; v = _v[block].loadAcquire(); - Q_ASSERT(v != 0); + Q_ASSERT(v != nullptr); } } - newid = v[at].next.load() | (id & ~ConstantsType::IndexMask); + newid = v[at].next.loadRelaxed() | (id & ~ConstantsType::IndexMask); } while (!_next.testAndSetRelease(id, newid)); // qDebug("QFreeList::next(): returning %d (_next now %d, serial %d)", // id & ConstantsType::IndexMask, @@ -271,12 +271,12 @@ inline void QFreeList<T, ConstantsType>::release(int id) { int at = id & ConstantsType::IndexMask; const int block = blockfor(at); - ElementType *v = _v[block].load(); + ElementType *v = _v[block].loadRelaxed(); int x, newid; do { x = _next.loadAcquire(); - v[at].next.store(x & ConstantsType::IndexMask); + v[at].next.storeRelaxed(x & ConstantsType::IndexMask); newid = incrementserial(x, id); } while (!_next.testAndSetRelease(x, newid)); |