From abd7496fba00a9de5f4c6e1ab9696f0679b8fac3 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Sun, 21 Mar 2021 11:23:30 +0100 Subject: [PATCH] QFutureInterfaceBasePrivate: reorder members to save 8 bytes And use in-class member initialization where applicable. Task-number: QTBUG-92045 Change-Id: I54715709f2d8e54017311f45016c16d86ed3078b Reviewed-by: Karsten Heimrich --- src/corelib/thread/qfutureinterface.cpp | 4 +-- src/corelib/thread/qfutureinterface_p.h | 33 +++++++++++++------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 7a8ba081030..50a1fcd5970 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -601,9 +601,7 @@ void QFutureInterfaceBase::reset() } QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState) - : refCount(1), m_progressValue(0), m_progressMinimum(0), m_progressMaximum(0), - state(initialState), - manualProgress(false), m_expectedResultCount(0), runnable(nullptr), m_pool(nullptr) + : state(initialState) { progressTime.invalidate(); } diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h index df71d3d4b66..25421b064ca 100644 --- a/src/corelib/thread/qfutureinterface_p.h +++ b/src/corelib/thread/qfutureinterface_p.h @@ -159,23 +159,30 @@ public: // T: accessed from executing thread // Q: accessed from the waiting/querying thread - RefCount refCount; mutable QMutex m_mutex; - QWaitCondition waitCondition; + QBasicMutex continuationMutex; QList outputConnections; - int m_progressValue; // TQ - int m_progressMinimum; // TQ - int m_progressMaximum; // TQ - QAtomicInt state; // reads and writes can happen unprotected, both must be atomic QElapsedTimer progressTime; + QWaitCondition waitCondition; QWaitCondition pausedWaitCondition; + // ### TODO: put m_results and m_exceptionStore into a union (see QTBUG-92045) QtPrivate::ResultStoreBase m_results; - bool manualProgress; // only accessed from executing thread - int m_expectedResultCount; QtPrivate::ExceptionStore m_exceptionStore; QString m_progressText; - QRunnable *runnable; - QThreadPool *m_pool; + QRunnable *runnable = nullptr; + QThreadPool *m_pool = nullptr; + // Wrapper for continuation + std::function continuation; + + RefCount refCount = 1; + QAtomicInt state; // reads and writes can happen unprotected, both must be atomic + int m_progressValue = 0; // TQ + int m_progressMinimum = 0; // TQ + int m_progressMaximum = 0; // TQ + int m_expectedResultCount = 0; + bool manualProgress = false; // only accessed from executing thread + bool launchAsync = false; + bool isValid = false; inline QThreadPool *pool() const { return m_pool ? m_pool : QThreadPool::globalInstance(); } @@ -194,12 +201,6 @@ public: void setState(QFutureInterfaceBase::State state); - // Wrapper for continuation - std::function continuation; - QBasicMutex continuationMutex; - - bool launchAsync = false; - bool isValid = false; }; QT_END_NAMESPACE