diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-04-28 20:08:33 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-04-30 20:52:23 +0000 |
commit | b2e143cc724f0e1a35cfa8ed5fe4142e33a884e7 (patch) | |
tree | 641916787ad7c8d5f2770531b2038064af210dd8 /src/core/jobs/qthreadpooler.cpp | |
parent | 62e0265408724f13c472904e0563007f19549fba (diff) |
QThreadPooler: aggregate mutex by value
There's no reason to incur a heap allocation for something
as simple as a mutex.
Change-Id: I9489b2348c142e028009b757d8f922fea43e168b
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/jobs/qthreadpooler.cpp')
-rw-r--r-- | src/core/jobs/qthreadpooler.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/core/jobs/qthreadpooler.cpp b/src/core/jobs/qthreadpooler.cpp index 35ec0c0c7..017b7f8db 100644 --- a/src/core/jobs/qthreadpooler.cpp +++ b/src/core/jobs/qthreadpooler.cpp @@ -58,7 +58,7 @@ QElapsedTimer QThreadPooler::m_jobsStatTimer; QThreadPooler::QThreadPooler(QObject *parent) : QObject(parent), m_futureInterface(Q_NULLPTR), - m_mutex(new QMutex(QMutex::NonRecursive)), + m_mutex(), m_taskCount(0) { // Ensures that threads will never be recycled @@ -71,16 +71,14 @@ QThreadPooler::QThreadPooler(QObject *parent) QThreadPooler::~QThreadPooler() { // Wait till all tasks are finished before deleting mutex - QMutexLocker locker(m_mutex); + QMutexLocker locker(&m_mutex); locker.unlock(); - - delete m_mutex; } void QThreadPooler::setDependencyHandler(DependencyHandler *handler) { m_dependencyHandler = handler; - m_dependencyHandler->setMutex(m_mutex); + m_dependencyHandler->setMutex(&m_mutex); } void QThreadPooler::enqueueTasks(const QVector<RunnableInterface *> &tasks) @@ -100,7 +98,7 @@ void QThreadPooler::enqueueTasks(const QVector<RunnableInterface *> &tasks) void QThreadPooler::taskFinished(RunnableInterface *task) { - const QMutexLocker locker(m_mutex); + const QMutexLocker locker(&m_mutex); release(); @@ -121,7 +119,7 @@ void QThreadPooler::taskFinished(RunnableInterface *task) QFuture<void> QThreadPooler::mapDependables(QVector<RunnableInterface *> &taskQueue) { - const QMutexLocker locker(m_mutex); + const QMutexLocker locker(&m_mutex); if (!m_futureInterface) m_futureInterface = new QFutureInterface<void>(); @@ -136,7 +134,7 @@ QFuture<void> QThreadPooler::mapDependables(QVector<RunnableInterface *> &taskQu QFuture<void> QThreadPooler::future() { - const QMutexLocker locker(m_mutex); + const QMutexLocker locker(&m_mutex); if (!m_futureInterface) return QFuture<void>(); |