summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qmutexpool.cpp20
-rw-r--r--src/corelib/thread/qmutexpool_p.h17
-rw-r--r--src/corelib/thread/qthread.cpp24
-rw-r--r--src/corelib/thread/qthread_p.h62
4 files changed, 69 insertions, 54 deletions
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index c5c1882..9f37239 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -42,7 +42,6 @@
#include "qatomic.h"
#include "qmutexpool_p.h"
-#ifndef QT_NO_THREAD
QT_BEGIN_NAMESPACE
@@ -50,6 +49,7 @@ QT_BEGIN_NAMESPACE
// use QMutexpool::instance() in new clode.
Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0;
Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
+#ifndef QT_NO_THREAD
/*!
\class QMutexPool
@@ -114,15 +114,6 @@ QMutexPool::~QMutexPool()
mutexes[index] = 0;
}
}
-
-/*!
- Returns the global QMutexPool instance.
-*/
-QMutexPool *QMutexPool::instance()
-{
- return globalMutexPool();
-}
-
/*!
Returns a QMutex from the pool. QMutexPool uses the value \a address
to determine which mutex is returned from the pool.
@@ -152,7 +143,14 @@ QMutex *QMutexPool::globalInstanceGet(const void *address)
return 0;
return globalInstance->get(address);
}
+#endif // QT_NO_THREAD
+/*!
+ Returns the global QMutexPool instance.
+*/
+QMutexPool *QMutexPool::instance()
+{
+ return globalMutexPool();
+}
QT_END_NAMESPACE
-#endif // QT_NO_THREAD
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index 3e1bad0..c26711b 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -57,9 +57,9 @@
#include "QtCore/qmutex.h"
#include "QtCore/qvarlengtharray.h"
-#ifndef QT_NO_THREAD
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_THREAD
class Q_CORE_EXPORT QMutexPool
{
@@ -75,11 +75,24 @@ private:
QVarLengthArray<QAtomicPointer<QMutex>, 131> mutexes;
QMutex::RecursionMode recursionMode;
};
+#else //QT_NO_THREAD
+Q_GLOBAL_STATIC(QMutex, globalMutex)
+class Q_CORE_EXPORT QMutexPool
+{
+public:
+ explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 131){}
+ ~QMutexPool(){}
+
+ QMutex *get(const void *address){return globalMutex();}
+ static QMutexPool *instance();
+ static QMutex *globalInstanceGet(const void *address){return globalMutex();}
+};
+
+#endif // QT_NO_THREAD
extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool;
QT_END_NAMESPACE
-#endif // QT_NO_THREAD
#endif // QMUTEXPOOL_P_H
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index ac191fe..cf57d33 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -727,6 +727,16 @@ QThread *QThread::currentThread()
return QThreadData::current()->thread;
}
+/*! \internal
+ */
+QThread::QThread(QThreadPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+ Q_D(QThread);
+ // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this);
+ d->data->thread = this;
+}
+
QThreadData* QThreadData::current()
{
static QThreadData *data = 0; // reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key));
@@ -738,17 +748,13 @@ QThreadData* QThreadData::current()
}
return data;
}
-
-/*! \internal
- */
-QThread::QThread(QThreadPrivate &dd, QObject *parent)
- : QObject(dd, parent)
+#endif // QT_NO_THREAD
+QThreadData* QThreadData::get2(QThread *thread)
{
- Q_D(QThread);
- // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this);
- d->data->thread = this;
+ Q_ASSERT_X(thread != 0, "QThread", "internal error");
+ return thread->d_func()->data;
}
-#endif // QT_NO_THREAD
+
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index af68434..8c3acdb 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -111,6 +111,36 @@ public:
{ }
};
+class QThreadData
+{
+ QAtomicInt _ref;
+
+public:
+ QThreadData(int initialRefCount = 1);
+ ~QThreadData();
+
+ static QThreadData *current();
+ static QThreadData *get2(QThread *thread);
+
+ void ref();
+ void deref();
+
+ QThread *thread;
+ bool quitNow;
+ int loopLevel;
+ QAbstractEventDispatcher *eventDispatcher;
+ QStack<QEventLoop *> eventLoops;
+ QPostEventList postEventList;
+ bool canWait;
+ QMap<int, void *> tls;
+
+ QMutex mutex;
+
+# ifdef Q_OS_SYMBIAN
+ RThread symbian_thread_handle;
+# endif
+};
+
#ifndef QT_NO_THREAD
class QThreadPrivate : public QObjectPrivate
{
@@ -179,38 +209,6 @@ public:
#endif // QT_NO_THREAD
-class QThreadData
-{
- QAtomicInt _ref;
-
-public:
- QThreadData(int initialRefCount = 1);
- ~QThreadData();
-
- static QThreadData *current();
- static QThreadData *get2(QThread *thread)
- { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; }
-
-
- void ref();
- void deref();
-
- QThread *thread;
- bool quitNow;
- int loopLevel;
- QAbstractEventDispatcher *eventDispatcher;
- QStack<QEventLoop *> eventLoops;
- QPostEventList postEventList;
- bool canWait;
- QMap<int, void *> tls;
-
- QMutex mutex;
-
-# ifdef Q_OS_SYMBIAN
- RThread symbian_thread_handle;
-# endif
-};
-
// thread wrapper for the main() thread
class QAdoptedThread : public QThread
{