summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-06-25 13:49:53 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-06-25 13:49:53 (GMT)
commitdb8f05e257019694f5e8076845626008f2adc3dd (patch)
tree05d3959403cf15ac5f702091439e028af01f343b /src/corelib/thread
parent8aafaa65a1d16f8b982279f5aceedf1e281ddb5a (diff)
parent796a5a2c7d8c91a46ac761dde18b7da2ec6c177b (diff)
downloadQt-db8f05e257019694f5e8076845626008f2adc3dd.zip
Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.gz
Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.bz2
Merge commit 'qt/master-stable' into 4.6-stable
Bring Qt 4.6 into the Qt-S60 repo. Conflicts: configure.exe mkspecs/features/qttest_p4.prf qmake/generators/makefile.cpp src/corelib/io/qdir.cpp src/corelib/io/qprocess.h src/corelib/kernel/qcoreevent.h src/corelib/kernel/qobject.cpp src/corelib/kernel/qsharedmemory_unix.cpp src/corelib/thread/qthread_p.h src/corelib/tools/qvector.h src/gui/dialogs/qdialog.cpp src/gui/dialogs/qfiledialog.cpp src/gui/dialogs/qfiledialog_p.h src/gui/dialogs/qmessagebox.cpp src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicsview.cpp src/gui/image/qpixmapcache.cpp src/gui/kernel/qapplication.cpp src/gui/kernel/qapplication_p.h src/gui/kernel/qwidget.cpp src/gui/kernel/qwidget_p.h src/gui/painting/qdrawhelper.cpp src/gui/painting/qpaintengine_raster.cpp src/gui/text/qfontengine_qpf.cpp src/gui/widgets/qmenubar.cpp src/network/socket/qlocalserver.cpp src/testlib/qtestcase.cpp src/testlib/testlib.pro tests/auto/qimagereader/tst_qimagereader.cpp tests/auto/qitemdelegate/tst_qitemdelegate.cpp tests/auto/qnetworkreply/tst_qnetworkreply.cpp tests/auto/qpixmap/qpixmap.pro
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qmutexpool.cpp20
-rw-r--r--src/corelib/thread/qmutexpool_p.h7
-rw-r--r--src/corelib/thread/qthread.cpp6
-rw-r--r--src/corelib/thread/qthread_p.h77
4 files changed, 45 insertions, 65 deletions
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index 96a9940..0d7c890 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
// qt_global_mutexpool is here for backwards compatability only,
// use QMutexpool::instance() in new clode.
Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0;
-Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (true))
+Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
/*!
\class QMutexPool
@@ -88,17 +88,17 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (true))
*/
/*!
- Constructs a QMutexPool, reserving space for \a size QMutexes. If
- \a recursive is true, all QMutexes in the pool will be recursive
- mutexes; otherwise they will all be non-recursive (the default).
+ Constructs a QMutexPool, reserving space for \a size QMutexes. All
+ mutexes in the pool are created with \a recursionMode. By default,
+ all mutexes are non-recursive.
The QMutexes are created when needed, and deleted when the
QMutexPool is destructed.
*/
-QMutexPool::QMutexPool(bool recursive, int size)
- : mutexes(size), count(size), recurs(recursive)
+QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size)
+ : mutexes(size), recursionMode(recursionMode)
{
- for (int index = 0; index < count; ++index) {
+ for (int index = 0; index < mutexes.count(); ++index) {
mutexes[index] = 0;
}
}
@@ -109,7 +109,7 @@ QMutexPool::QMutexPool(bool recursive, int size)
*/
QMutexPool::~QMutexPool()
{
- for (int index = 0; index < count; ++index) {
+ for (int index = 0; index < mutexes.count(); ++index) {
delete mutexes[index];
mutexes[index] = 0;
}
@@ -130,11 +130,11 @@ QMutexPool *QMutexPool::instance()
QMutex *QMutexPool::get(const void *address)
{
Q_ASSERT_X(address != 0, "QMutexPool::get()", "'address' argument cannot be zero");
- int index = int((quintptr(address) >> (sizeof(address) >> 1)) % count);
+ int index = int((quintptr(address) >> (sizeof(address) >> 1)) % mutexes.count());
if (!mutexes[index]) {
// mutex not created, create one
- QMutex *newMutex = new QMutex(recurs ? QMutex::Recursive : QMutex::NonRecursive);
+ QMutex *newMutex = new QMutex(recursionMode);
if (!mutexes[index].testAndSetOrdered(0, newMutex))
delete newMutex;
}
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index 1009ebb..30a16d4 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QMutexPool
{
public:
- explicit QMutexPool(bool recursive = false, int size = 128);
+ explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 131);
~QMutexPool();
QMutex *get(const void *address);
@@ -72,9 +72,8 @@ public:
static QMutex *globalInstanceGet(const void *address);
private:
- QVarLengthArray<QAtomicPointer<QMutex>, 128> mutexes;
- int count;
- bool recurs;
+ QVarLengthArray<QAtomicPointer<QMutex>, 131> mutexes;
+ QMutex::RecursionMode recursionMode;
};
extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool;
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index f1bdc64..a2b944d 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -113,12 +113,6 @@ QThreadData::~QThreadData()
// fprintf(stderr, "QThreadData %p destroyed\n", this);
}
-QThreadData *QThreadData::get2(QThread *thread)
-{
- Q_ASSERT_X(thread != 0, "QThread", "internal error");
- return thread->d_func()->data;
-}
-
void QThreadData::ref()
{
#ifndef QT_NO_THREAD
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 0bf773c..c575005 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -111,51 +111,6 @@ public:
{ }
};
-class Q_CORE_EXPORT 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
-};
-
-// thread wrapper for the main() thread
-class QAdoptedThread : public QThread
-{
- Q_DECLARE_PRIVATE(QThread)
-
-public:
- QAdoptedThread(QThreadData *data = 0);
- ~QAdoptedThread();
- void init();
-
- static QThread *createThreadForAdoption();
-private:
- void run();
-};
-
#ifndef QT_NO_THREAD
class QThreadPrivate : public QObjectPrivate
{
@@ -224,6 +179,38 @@ 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
+};
+
QT_END_NAMESPACE
#endif // QTHREAD_P_H