diff options
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qmutex.h | 9 | ||||
-rw-r--r-- | src/corelib/thread/qmutex_unix.cpp | 5 | ||||
-rw-r--r-- | src/corelib/thread/qthread.cpp | 10 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 2 | ||||
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 28 | ||||
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 5 | ||||
-rw-r--r-- | src/corelib/thread/thread.pri | 4 |
7 files changed, 50 insertions, 13 deletions
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index dfe4aae..5f75195 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -163,6 +163,7 @@ class QMutexData ~QMutexData(); }; +#ifdef QT_NO_DEBUG inline void QMutex::unlockInline() { if (d->recursive) { @@ -189,7 +190,13 @@ inline void QMutex::lockInline() lockInternal(); } } - +#else // QT_NO_DEBUG +//in debug we do not use inline calls in order to allow debugging tools +// to hook the mutex locking functions. +inline void QMutex::unlockInline() { unlock(); } +inline bool QMutex::tryLockInline() { return tryLock(); } +inline void QMutex::lockInline() { lock(); } +#endif // QT_NO_DEBUG #else // QT_NO_THREAD diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index 5321252..11e2060 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -180,8 +180,11 @@ bool QMutexPrivate::wait(int timeout) errorCode = pthread_cond_timedwait(&cond, &mutex, &ti); } if (errorCode) { - if (errorCode == ETIMEDOUT) + if (errorCode == ETIMEDOUT) { + if (wakeup) + errorCode = 0; break; + } report_error(errorCode, "QMutex::lock()", "cv wait"); } } diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 1494745..326f494 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -515,10 +515,12 @@ int QThread::exec() Note that unlike the C library function of the same name, this function \e does return to the caller -- it is event processing - that stops. - - This function does nothing if the thread does not have an event - loop. + that stops. + + No QEventLoops will be started anymore in this thread until + QThread::exec() has been called again. If the eventloop in QThread::exec() + is not running then the next call to QThread::exec() will also return + immediately. \sa quit() QEventLoop */ diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 9a2dbec..36e07c0 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -209,8 +209,6 @@ public: bool canWait; QVector<void *> tls; - QMutex mutex; - # ifdef Q_OS_SYMBIAN RThread symbian_thread_handle; # endif diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 0766447..5e0d2a2 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -110,6 +110,17 @@ QT_BEGIN_NAMESPACE enum { ThreadPriorityResetFlag = 0x80000000 }; +#if defined(Q_OS_LINUX) && defined(__GLIBC__) && (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) +#define HAVE_TLS +#endif +#if defined(Q_CC_XLC) || defined (Q_CC_SUN) +#define HAVE_TLS +#endif + +#ifdef HAVE_TLS +static __thread QThreadData *currentThreadData = 0; +#endif + static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT; static pthread_key_t current_thread_data_key; @@ -157,7 +168,9 @@ Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key) // that pthread has, so pthread_setspecific is also used. static QThreadData *get_thread_data() { -#ifdef Q_OS_SYMBIAN +#ifdef HAVE_TLS + return currentThreadData; +#elif defined Q_OS_SYMBIAN return reinterpret_cast<QThreadData *>(Dll::Tls()); #else pthread_once(¤t_thread_data_once, create_current_thread_data_key); @@ -167,7 +180,9 @@ static QThreadData *get_thread_data() static void set_thread_data(QThreadData *data) { -#ifdef Q_OS_SYMBIAN +#ifdef HAVE_TLS + currentThreadData = data; +#elif defined Q_OS_SYMBIAN qt_symbian_throwIfError(Dll::SetTls(data)); #endif pthread_once(¤t_thread_data_once, create_current_thread_data_key); @@ -176,7 +191,9 @@ static void set_thread_data(QThreadData *data) static void clear_thread_data() { -#ifdef Q_OS_SYMBIAN +#ifdef HAVE_TLS + currentThreadData = 0; +#elif defined Q_OS_SYMBIAN Dll::FreeTls(); #endif pthread_setspecific(current_thread_data_key, 0); @@ -310,7 +327,10 @@ void *QThreadPrivate::start(void *arg) set_thread_data(data); data->ref(); - data->quitNow = false; + { + QMutexLocker locker(&thr->d_func()->mutex); + data->quitNow = thr->d_func()->exited; + } // ### TODO: allow the user to create a custom event dispatcher createEventDispatcher(data); diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index cb2d1a9..6b7932b 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -298,7 +298,10 @@ unsigned int __stdcall QThreadPrivate::start(void *arg) QThread::setTerminationEnabled(false); - data->quitNow = false; + { + QMutexLocker locker(&thr->d_func()->mutex); + data->quitNow = thr->d_func()->exited; + } // ### TODO: allow the user to create a custom event dispatcher createEventDispatcher(data); diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index 03f661d..90583bb 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -31,3 +31,7 @@ unix:SOURCES += thread/qmutex_unix.cpp \ win32:SOURCES += thread/qmutex_win.cpp \ thread/qthread_win.cpp \ thread/qwaitcondition_win.cpp + +integrity:SOURCES += thread/qmutex_unix.cpp \ + thread/qthread_unix.cpp \ + thread/qwaitcondition_unix.cpp |