summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex_p.h
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2015-11-06 12:19:19 +0100
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2016-01-04 08:40:18 +0000
commitc7ab816af110ea08809e1aabd8bf1e08967c6d53 (patch)
tree6db83c7a48d51dd3c376c3c80425efc4a2131661 /src/corelib/thread/qmutex_p.h
parente0c8316e1782a34bf2c67ed1e6901d750cf30fb3 (diff)
qmutex_unix: use a semaphore when available
It makes tst_QMutex::contendedQMutex with no msleep 8 times faster Change-Id: Ic300e7618b4467e4e08b30f0213bd23c06d4d90a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qmutex_p.h')
-rw-r--r--src/corelib/thread/qmutex_p.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index 3ca742b194..191edda6d1 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -55,11 +55,14 @@
#if defined(Q_OS_MAC)
# include <mach/semaphore.h>
-#endif
-
-#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
+#elif defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
// use Linux mutexes everywhere except for LSB builds
# define QT_LINUX_FUTEX
+#elif defined(Q_OS_UNIX)
+# if _POSIX_VERSION-0 >= 200112L || _XOPEN_VERSION-0 >= 600
+# include <semaphore.h>
+# define QT_UNIX_SEMAPHORE
+# endif
#endif
struct timespec;
@@ -120,6 +123,8 @@ public:
//platform specific stuff
#if defined(Q_OS_MAC)
semaphore_t mach_semaphore;
+#elif defined(QT_UNIX_SEMAPHORE)
+ sem_t semaphore;
#elif defined(Q_OS_UNIX)
bool wakeup;
pthread_mutex_t mutex;