OSDN Git Service

QTHread and QMutexPool cleanups
authorIvailo Monev <xakepa10@gmail.com>
Fri, 22 Jul 2016 23:06:50 +0000 (23:06 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 22 Jul 2016 23:06:50 +0000 (23:06 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/kernel/qcoreapplication.cpp
src/core/thread/qmutexpool.cpp
src/core/thread/qmutexpool_p.h
src/core/thread/qthread.cpp
src/core/thread/qthread.h
src/core/thread/qthread_p.h

index 395ecb6..e52b4fc 100644 (file)
@@ -606,11 +606,6 @@ void QCoreApplication::init()
     Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
     QCoreApplication::self = this;
 
-
-#ifndef QT_NO_THREAD
-    QThread::initialize();
-#endif
-
     // use the event dispatcher created by the app programmer (if any)
     if (!QCoreApplicationPrivate::eventDispatcher)
         QCoreApplicationPrivate::eventDispatcher = d->threadData->eventDispatcher;
@@ -657,8 +652,7 @@ QCoreApplication::~QCoreApplication()
     QCoreApplicationPrivate::is_app_closing = true;
     QCoreApplicationPrivate::is_app_running = false;
 
-#if !defined(QT_NO_THREAD)
-#if !defined(QT_NO_CONCURRENT)
+#if !defined(QT_NO_THREAD) && !defined(QT_NO_CONCURRENT)
     // Synchronize and stop the global thread pool threads.
     QThreadPool *globalThreadPool = 0;
     QT_TRY {
@@ -669,8 +663,6 @@ QCoreApplication::~QCoreApplication()
     if (globalThreadPool)
         globalThreadPool->waitForDone();
 #endif
-    QThread::cleanup();
-#endif
 
     d_func()->threadData->eventDispatcher = 0;
     if (QCoreApplicationPrivate::eventDispatcher)
index a284663..2a88bcb 100644 (file)
@@ -46,9 +46,6 @@
 
 QT_BEGIN_NAMESPACE
 
-// qt_global_mutexpool is here for backwards compatibility only,
-// use QMutexpool::instance() in new clode.
-Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0;
 Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
 
 /*!
index d4a5dc1..dd93a7e 100644 (file)
@@ -84,8 +84,6 @@ private:
     QMutex::RecursionMode recursionMode;
 };
 
-extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool;
-
 QT_END_NAMESPACE
 
 #endif // QT_NO_THREAD
index b51d17f..dcd4cc4 100644 (file)
@@ -77,8 +77,8 @@ QT_BEGIN_NAMESPACE
 */
 
 QThreadData::QThreadData(int initialRefCount)
-    : _ref(initialRefCount), thread(0), threadId(0),
-      quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true), isAdopted(false)
+    : _ref(initialRefCount), quitNow(false), canWait(true), isAdopted(false),
+        loopLevel(0), threadId(0), thread(0), eventDispatcher(0)
 {
     // fprintf(stderr, "QThreadData %p created\n", this);
 }
@@ -599,33 +599,6 @@ void QThread::run()
     (void) exec();
 }
 
-/*! \internal
-    Initializes the QThread system.
-*/
-#if defined (Q_OS_WIN)
-void qt_create_tls();
-#endif
-
-void QThread::initialize()
-{
-    if (qt_global_mutexpool)
-        return;
-    qt_global_mutexpool = QMutexPool::instance();
-
-#if defined (Q_OS_WIN)
-    qt_create_tls();
-#endif
-}
-
-
-/*! \internal
-    Cleans up the QThread system.
-*/
-void QThread::cleanup()
-{
-    qt_global_mutexpool = 0;
-}
-
 /*!
     \fn bool QThread::finished() const
 
index 174cb68..cd46879 100644 (file)
@@ -121,9 +121,6 @@ private:
     Q_OBJECT
     Q_DECLARE_PRIVATE(QThread)
 
-    static void initialize();
-    static void cleanup();
-
     friend class QCoreApplication;
     friend class QThreadData;
 };
index 6ed923f..7c0fb08 100644 (file)
@@ -199,8 +199,6 @@ public:
 
 class QThreadData
 {
-    QAtomicInt _ref;
-
 public:
     QThreadData(int initialRefCount = 1);
     ~QThreadData();
@@ -248,18 +246,21 @@ public:
         }
     };
 
-    QThread *thread;
-    Qt::HANDLE threadId;
+private:
+    QAtomicInt _ref;
+
+public:
     bool quitNow;
-    int loopLevel;
-    QAbstractEventDispatcher *eventDispatcher;
-    QStack<QEventLoop *> eventLoops;
-    QPostEventList postEventList;
     bool canWait;
-    QVector<void *> tls;
     bool isAdopted;
+    int loopLevel;
 
-
+    Qt::HANDLE threadId;
+    QStack<QEventLoop *> eventLoops;
+    QVector<void *> tls;
+    QThread *thread;
+    QAbstractEventDispatcher *eventDispatcher;
+    QPostEventList postEventList;
     FlaggedDebugSignatures flaggedSignatures;
 };