diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-04-21 18:17:08 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-05-18 10:32:31 (GMT) |
commit | c25a6e090c8074e68d7eb40f2533da8bab5e7dd8 (patch) | |
tree | 0d881265383a23871aa6f93c02f756b5dc8d36e1 /src/corelib/thread/qmutex_p.h | |
parent | aef03d80f7d9b71dfe777cd7927808d69dac0c27 (diff) | |
download | Qt-c25a6e090c8074e68d7eb40f2533da8bab5e7dd8.zip Qt-c25a6e090c8074e68d7eb40f2533da8bab5e7dd8.tar.gz Qt-c25a6e090c8074e68d7eb40f2533da8bab5e7dd8.tar.bz2 |
Inline the common case when there is no contention.
QMutex locking could be used in performence critical code (such
as QObject and co.) where the cost of a function call is
not neglectible. This would slow down the common case where
there is only one thread and no contention.
Since we need to keep the old symbol for binary compatibilty, introduce
new *Inline function.
Reviewed-by: Brad
Diffstat (limited to 'src/corelib/thread/qmutex_p.h')
-rw-r--r-- | src/corelib/thread/qmutex_p.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h index dce162a..6126423 100644 --- a/src/corelib/thread/qmutex_p.h +++ b/src/corelib/thread/qmutex_p.h @@ -56,10 +56,11 @@ #include <QtCore/qglobal.h> #include <QtCore/qnamespace.h> +#include <QtCore/qmutex.h> QT_BEGIN_NAMESPACE -class QMutexPrivate { +class QMutexPrivate : public QMutexData { public: QMutexPrivate(QMutex::RecursionMode mode); ~QMutexPrivate(); @@ -68,8 +69,6 @@ public: bool wait(int timeout = -1); void wakeUp(); - const bool recursive; - QAtomicInt contenders; volatile int lastSpinCount; Qt::HANDLE owner; uint count; @@ -83,6 +82,12 @@ public: #endif }; +inline QMutexData::QMutexData(QMutex::RecursionMode mode) + : recursive(mode == QMutex::Recursive) +{} + +inline QMutexData::~QMutexData() {} + QT_END_NAMESPACE #endif // QMUTEX_P_H |