summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-07-26 10:44:55 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-29 10:32:16 +0200
commitddf444d31a7cb961b79190131cb679fd7a6351fd (patch)
tree2fd1da740c8e89de4e4ef810e5dc3d7baf5616b1
parent86a237929e2b67ce333b635b760e78c628effb60 (diff)
Simplify the mutexpool used in QObject.
Since we now have QBasicMutex as a POD, we can simplify the mutexpool. This remove the call the the Q_GLOBAL_STATIC and some others tests that are taking CPU cycles when activating a signal. The QMutexPool class itself can't be simplified because its mutex are recursive mutexes, and the size is dynamic. also it is harder to get all the mutexes initialized to 0. Change-Id: Ie781655635907d2ad620eb189099cba14638414f Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/2171 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
-rw-r--r--src/corelib/kernel/qobject.cpp24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index ab9314ce53..076744ee00 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -60,7 +60,6 @@
#include <qsharedpointer.h>
#include <private/qorderedmutexlocker_p.h>
-#include <private/qmutexpool_p.h>
#include <new>
@@ -95,35 +94,22 @@ static int *queuedConnectionTypes(const QList<QByteArray> &typeNames)
return types;
}
-static QBasicAtomicPointer<QMutexPool> signalSlotMutexes = Q_BASIC_ATOMIC_INITIALIZER(0);
-static QBasicAtomicInt objectCount = Q_BASIC_ATOMIC_INITIALIZER(0);
+static QBasicMutex _q_ObjectMutexPool[131];
/** \internal
* mutex to be locked when accessing the connectionlists or the senders list
*/
static inline QMutex *signalSlotLock(const QObject *o)
{
- if (!signalSlotMutexes) {
- QMutexPool *mp = new QMutexPool;
- if (!signalSlotMutexes.testAndSetOrdered(0, mp)) {
- delete mp;
- }
- }
- return signalSlotMutexes->get(o);
+ return static_cast<QMutex *>(&_q_ObjectMutexPool[
+ uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]);
}
extern "C" Q_CORE_EXPORT void qt_addObject(QObject *)
-{
- objectCount.ref();
-}
+{}
extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
-{
- if(!objectCount.deref()) {
- QMutexPool *old = signalSlotMutexes.fetchAndStoreAcquire(0);
- delete old;
- }
-}
+{}
struct QConnectionSenderSwitcher {
QObject *receiver;