From 90b22d995ff7a05956b7549003a88ebf11f5d588 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Tue, 26 May 2015 10:56:59 +0300 Subject: ThreadPooler future reservation under mutex Added mutex for QFuture reservation on QThreadPooler Change-Id: I6fc399c2518180d78a7ed387a90330af02b1b8a5 Reviewed-by: Miikka Heikkinen --- src/core/jobs/qthreadpooler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/jobs/qthreadpooler.cpp b/src/core/jobs/qthreadpooler.cpp index 94d5b29c2..b5d7ba10b 100644 --- a/src/core/jobs/qthreadpooler.cpp +++ b/src/core/jobs/qthreadpooler.cpp @@ -119,6 +119,8 @@ QFuture QThreadPooler::mapDependables(QVector &taskQu QFuture QThreadPooler::future() { + const QMutexLocker locker(m_mutex); + if (!m_futureInterface) return QFuture(); else @@ -127,6 +129,8 @@ QFuture QThreadPooler::future() void QThreadPooler::acquire(int add) { + // The caller have to set the mutex + forever { int localCount = m_taskCount.load(); if (m_taskCount.testAndSetOrdered(localCount, localCount + add)) @@ -136,6 +140,8 @@ void QThreadPooler::acquire(int add) void QThreadPooler::release() { + // The caller have to set the mutex + forever { int localCount = m_taskCount.load(); @@ -149,6 +155,8 @@ void QThreadPooler::release() int QThreadPooler::currentCount() { + // The caller have to set the mutex + return m_taskCount.load(); } -- cgit v1.2.3