summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-06-28 12:13:57 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-31 11:47:10 +0200
commit9a7fc48ba656ef2ba5c5f43926346a7af417d121 (patch)
treefec9543e7bf7bc0b9eb70a6f96c69a2076f70c3f
parent238ea650cc711668b4c55fe5f208fba31da98b57 (diff)
Port from QMutex::Recursive to QRecursiveMutex
Also port from QMutexLocker to std::lock_guard, as the former will not support QRecursiveMutex going forward. Change-Id: I65e14492fc0583e5d0018aef64e18db8a6023dc8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/core/qchangearbiter.cpp21
-rw-r--r--src/core/qchangearbiter_p.h2
2 files changed, 12 insertions, 11 deletions
diff --git a/src/core/qchangearbiter.cpp b/src/core/qchangearbiter.cpp
index e0ee389c4..8cfc4b066 100644
--- a/src/core/qchangearbiter.cpp
+++ b/src/core/qchangearbiter.cpp
@@ -51,6 +51,8 @@
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/private/qsceneobserverinterface_p.h>
+#include <mutex>
+
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
@@ -76,7 +78,6 @@ namespace Qt3DCore {
*/
QChangeArbiter::QChangeArbiter(QObject *parent)
: QObject(parent)
- , m_mutex(QMutex::Recursive)
, m_jobManager(nullptr)
, m_postman(nullptr)
, m_scene(nullptr)
@@ -151,31 +152,31 @@ QThreadStorage<QChangeArbiter::QChangeQueue *> *QChangeArbiter::tlsChangeQueue()
void QChangeArbiter::appendChangeQueue(QChangeArbiter::QChangeQueue *queue)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
m_changeQueues.append(queue);
}
void QChangeArbiter::removeChangeQueue(QChangeArbiter::QChangeQueue *queue)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
m_changeQueues.removeOne(queue);
}
void QChangeArbiter::appendLockingChangeQueue(QChangeArbiter::QChangeQueue *queue)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
m_lockingChangeQueues.append(queue);
}
void QChangeArbiter::removeLockingChangeQueue(QChangeArbiter::QChangeQueue *queue)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
m_lockingChangeQueues.removeOne(queue);
}
void QChangeArbiter::syncChanges()
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
for (QChangeArbiter::QChangeQueue *changeQueue : qAsConst(m_changeQueues))
distributeQueueChanges(changeQueue);
@@ -202,7 +203,7 @@ void QChangeArbiter::registerObserver(QObserverInterface *observer,
QNodeId nodeId,
ChangeFlags changeFlags)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
QObserverList &observerList = m_nodeObservations[nodeId];
observerList.append(QObserverPair(changeFlags, observer));
}
@@ -216,7 +217,7 @@ void QChangeArbiter::registerSceneObserver(QSceneObserverInterface *observer)
void QChangeArbiter::unregisterObserver(QObserverInterface *observer, QNodeId nodeId)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
const auto it = m_nodeObservations.find(nodeId);
if (it != m_nodeObservations.end()) {
QObserverList &observers = it.value();
@@ -251,13 +252,13 @@ void QChangeArbiter::sceneChangeEvent(const QSceneChangePtr &e)
void QChangeArbiter::sceneChangeEventWithLock(const QSceneChangePtr &e)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
sceneChangeEvent(e);
}
void QChangeArbiter::sceneChangeEventWithLock(const QSceneChangeList &e)
{
- QMutexLocker locker(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> locker(m_mutex);;
QChangeQueue *localChangeQueue = m_tlsChangeQueue.localData();
qCDebug(ChangeArbiter) << Q_FUNC_INFO << "Handles " << e.size() << " changes at once";
localChangeQueue->insert(localChangeQueue->end(), e.begin(), e.end());
diff --git a/src/core/qchangearbiter_p.h b/src/core/qchangearbiter_p.h
index ac52273ea..1f453ff56 100644
--- a/src/core/qchangearbiter_p.h
+++ b/src/core/qchangearbiter_p.h
@@ -137,7 +137,7 @@ protected:
void removeLockingChangeQueue(QChangeQueue *queue);
private:
- mutable QMutex m_mutex;
+ mutable QRecursiveMutex m_mutex;
QAbstractAspectJobManager *m_jobManager;
// The lists of observers indexed by observable (QNodeId).