summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-06-17 10:53:42 +0200
committerLiang Qi <liang.qi@qt.io>2016-06-17 10:53:42 +0200
commit3cb56800d581dabd18e354a24f018c55bd91f748 (patch)
tree9b8e95cf62e22026463a0f87a3625b279f457aad /src/corelib/thread
parentaed7540d45096791d1a824f500694a15426fd94b (diff)
parent3d8c8daae109fbd6d60e43c3d4457b581e5e62a3 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp Change-Id: If899cda251b4dc8b8a7c6764520e88ab719737cd
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qmutexpool.cpp11
-rw-r--r--src/corelib/thread/qmutexpool_p.h5
-rw-r--r--src/corelib/thread/qreadwritelock_p.h2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index 522fd5eac2..90b6989467 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -92,10 +92,11 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
QMutexPool is destructed.
*/
QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size)
- : count(size),
- mutexes(new QAtomicPointer<QMutex>[size]()), // (): zero-initialize
- recursionMode(recursionMode)
+ : mutexes(size), recursionMode(recursionMode)
{
+ for (int index = 0; index < mutexes.count(); ++index) {
+ mutexes[index].store(0);
+ }
}
/*!
@@ -104,8 +105,8 @@ QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size)
*/
QMutexPool::~QMutexPool()
{
- qDeleteAll(mutexes, mutexes + count);
- delete[] mutexes;
+ for (int index = 0; index < mutexes.count(); ++index)
+ delete mutexes[index].load();
}
/*!
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index 33e9a52cb7..796e65d960 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -66,7 +66,7 @@ public:
~QMutexPool();
inline QMutex *get(const void *address) {
- int index = uint(quintptr(address)) % count;
+ int index = uint(quintptr(address)) % mutexes.count();
QMutex *m = mutexes[index].load();
if (m)
return m;
@@ -78,8 +78,7 @@ public:
private:
QMutex *createMutex(int index);
- int count;
- QAtomicPointer<QMutex> *mutexes;
+ QVarLengthArray<QAtomicPointer<QMutex>, 131> mutexes;
QMutex::RecursionMode recursionMode;
};
diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h
index 285f017655..24d25eb2be 100644
--- a/src/corelib/thread/qreadwritelock_p.h
+++ b/src/corelib/thread/qreadwritelock_p.h
@@ -65,7 +65,7 @@ class QReadWriteLockPrivate
public:
QReadWriteLockPrivate(bool isRecursive = false)
: readerCount(0), writerCount(0), waitingReaders(0), waitingWriters(0),
- recursive(isRecursive), id(0) {}
+ recursive(isRecursive), id(0), currentWriter(nullptr) {}
QMutex mutex;
QWaitCondition writerCond;