From d9919f1852441d591b12bf50da6a3b6b5fa53087 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Aug 2019 13:15:29 +0200 Subject: QFutureInterface: clean up mutex() method for Qt 6 Ditch the QMutex *mutex() method that we had to keep around for binary compatibility and drop the disambiguation argument of QMutex &mutex(int) now that we don't need it anymore. The lock_guard lines now look dangerously close to C++'s Most Vexing Parse, so use braced initialization to make sure it's parsed as a definition, not a declaration. Change-Id: Ie3d70f58c9878ab6d7da8f8bd72a4cb4aff83bb7 Reviewed-by: Edward Welbourne Reviewed-by: Volker Hilsheimer --- src/corelib/thread/qfutureinterface.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/corelib/thread/qfutureinterface.h') diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index bcdae24833..43dfd6bac4 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -119,8 +119,7 @@ public: void waitForResult(int resultIndex); void waitForResume(); - QMutex *mutex() const; - QMutex &mutex(int) const; + QMutex &mutex() const; QtPrivate::ExceptionStore &exceptionStore(); QtPrivate::ResultStoreBase &resultStoreBase(); const QtPrivate::ResultStoreBase &resultStoreBase() const; @@ -191,7 +190,7 @@ public: template inline void QFutureInterface::reportResult(const T *result, int index) { - std::lock_guard locker(mutex(0)); + std::lock_guard locker{mutex()}; if (this->queryState(Canceled) || this->queryState(Finished)) { return; } @@ -217,7 +216,7 @@ inline void QFutureInterface::reportResult(const T &result, int index) template inline void QFutureInterface::reportResults(const QVector &_results, int beginIndex, int count) { - std::lock_guard locker(mutex(0)); + std::lock_guard locker{mutex()}; if (this->queryState(Canceled) || this->queryState(Finished)) { return; } @@ -245,14 +244,14 @@ inline void QFutureInterface::reportFinished(const T *result) template inline const T &QFutureInterface::resultReference(int index) const { - std::lock_guard locker(mutex(0)); + std::lock_guard locker{mutex()}; return resultStoreBase().resultAt(index).template value(); } template inline const T *QFutureInterface::resultPointer(int index) const { - std::lock_guard locker(mutex(0)); + std::lock_guard locker{mutex()}; return resultStoreBase().resultAt(index).template pointer(); } @@ -266,7 +265,7 @@ inline QList QFutureInterface::results() QFutureInterfaceBase::waitForResult(-1); QList res; - std::lock_guard locker(mutex(0)); + std::lock_guard locker{mutex()}; QtPrivate::ResultIteratorBase it = resultStoreBase().begin(); while (it != resultStoreBase().end()) { -- cgit v1.2.3