summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex_p.h
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@kde.org>2011-10-20 17:11:18 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-31 12:16:11 +0100
commit73b682d816ec12afbf8064a44e462dd89e4c38df (patch)
tree667bc44e7fce3b618b2ceb3e70b7d087f7bff77b /src/corelib/thread/qmutex_p.h
parent72257f642944a347b806ac34934d0fb8bc472b1c (diff)
QRecursiveMutexPrivate should not inherit from QMutexPrivate
QMutexPrivate takes more memory than necessary, and also initialize platform specific ressources. Change-Id: I70be1b89b1c21499645785ae47693a6b2514e28b Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/corelib/thread/qmutex_p.h')
-rw-r--r--src/corelib/thread/qmutex_p.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index 00bda48e5b..e385181e0f 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -65,15 +65,23 @@
QT_BEGIN_NAMESPACE
-class QMutexPrivate {
+class QMutexData
+{
+public:
+ bool recursive;
+ QMutexData(QMutex::RecursionMode mode = QMutex::NonRecursive)
+ : recursive(mode == QMutex::Recursive) {}
+};
+
+#if !defined(Q_OS_LINUX)
+class QMutexPrivate : public QMutexData {
public:
~QMutexPrivate();
- QMutexPrivate(QMutex::RecursionMode mode = QMutex::NonRecursive);
+ QMutexPrivate();
bool wait(int timeout = -1);
void wakeUp();
-#if !defined(Q_OS_LINUX)
// Conrol the lifetime of the privates
QAtomicInt refCount;
int id;
@@ -102,15 +110,11 @@ public:
QAtomicInt possiblyUnlocked; //bool saying that a timed wait timed out
enum { BigNumber = 0x100000 }; //Must be bigger than the possible number of waiters (number of threads)
void derefWaiters(int value);
-#endif
-
- // handle recursive mutex
- bool recursive;
//platform specific stuff
#if defined(Q_OS_MAC)
semaphore_t mach_semaphore;
-#elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
+#elif defined(Q_OS_UNIX)
bool wakeup;
pthread_mutex_t mutex;
pthread_cond_t cond;
@@ -118,12 +122,13 @@ public:
HANDLE event;
#endif
};
+#endif //Q_OS_LINUX
-class QRecursiveMutexPrivate : public QMutexPrivate
+class QRecursiveMutexPrivate : public QMutexData
{
public:
QRecursiveMutexPrivate()
- : QMutexPrivate(QMutex::Recursive), owner(0), count(0) {}
+ : QMutexData(QMutex::Recursive), owner(0), count(0) {}
Qt::HANDLE owner;
uint count;
QMutex mutex;