diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-28 16:54:06 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-31 14:32:42 (GMT) |
commit | df9491b302f6404ad2ccc6dc2eb3377176d994c6 (patch) | |
tree | ea041707bfae4eb5586b3b67c7f24b9a262e09c0 /src/corelib/thread | |
parent | 3ae213cdeffae107ffa5a4b552c6351123dcc5cb (diff) | |
download | Qt-df9491b302f6404ad2ccc6dc2eb3377176d994c6.zip Qt-df9491b302f6404ad2ccc6dc2eb3377176d994c6.tar.gz Qt-df9491b302f6404ad2ccc6dc2eb3377176d994c6.tar.bz2 |
Optimize QMetaObject::activate (remove call to QThreadData::current)
QThreadData::current is too slow, it needs to access the TLS
The currentThreadId is much faster.
Reviewed-by: Brad
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qthread.cpp | 2 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 2 | ||||
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 3 | ||||
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 2 |
4 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 817e73e..acf0fce 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -77,7 +77,7 @@ QT_BEGIN_NAMESPACE */ QThreadData::QThreadData(int initialRefCount) - : _ref(initialRefCount), thread(0), + : _ref(initialRefCount), thread(0), threadId(0), quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true), isAdopted(false) { // fprintf(stderr, "QThreadData %p created\n", this); diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 2413452..b43a456 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -146,6 +146,7 @@ public: #else static void finish(void *); #endif + #endif // Q_OS_UNIX #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) @@ -201,6 +202,7 @@ public: void deref(); QThread *thread; + Qt::HANDLE threadId; bool quitNow; int loopLevel; QAbstractEventDispatcher *eventDispatcher; diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 484b455..787c909 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -261,6 +261,7 @@ QThreadData *QThreadData::current() data->deref(); } data->isAdopted = true; + data->threadId = (Qt::HANDLE)pthread_self(); if (!QCoreApplicationPrivate::theMainThread) QCoreApplicationPrivate::theMainThread = data->thread; } @@ -344,7 +345,7 @@ void *QThreadPrivate::start(void *arg) // attribute of the thread again once the app gains control in run() User::SetCritical(User::EProcessCritical); #endif - + data->threadId = (Qt::HANDLE)pthread_self(); set_thread_data(data); data->ref(); diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index b9c55b0..bab6cf8 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -125,6 +125,7 @@ QThreadData *QThreadData::current() threadData->deref(); } threadData->isAdopted = true; + threadData->threadId = (Qt::HANDLE)GetCurrentThreadId(); if (!QCoreApplicationPrivate::theMainThread) { QCoreApplicationPrivate::theMainThread = threadData->thread; @@ -306,6 +307,7 @@ unsigned int __stdcall QThreadPrivate::start(void *arg) qt_create_tls(); TlsSetValue(qt_current_thread_data_tls_index, data); + data->threadId = (Qt::HANDLE)GetCurrentThreadId(); QThread::setTerminationEnabled(false); |