summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qsemaphore.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-08-26 00:38:51 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-10-23 05:09:22 +0000
commit895cb4681ee78caaf9b99c88390a74ff1d79ae61 (patch)
tree2adf788ad4f97ae3fe4e1e567457bbd999e66b15 /src/corelib/thread/qsemaphore.h
parentbf15e22cee235b31f43032e7b9862926a92fa75c (diff)
QSemaphore: Improve waking up on 64-bit Linux
By judiciously positioning of the bits, we can optimize for the case of threads trying to acquire a single token, which is what QSemaphore should be mostly used for, as it matches the POSIX Semaphore API (sem_wait, sem_timedwait and sem_trywait). If there are only waiters waiting for a single token, we know that adding n tokens means n threads can wake up. This optimizes for multi-token waiters too. For example, if we have 50 single-token waiters and 50 multi-token waiters, a sem.release(5) will wake up 55 threads instead of 100. Change-Id: I209fcd5dbc2b4e5381cffffd14de5550c75d2600 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/thread/qsemaphore.h')
-rw-r--r--src/corelib/thread/qsemaphore.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h
index 03ffa033d8..c41f258577 100644
--- a/src/corelib/thread/qsemaphore.h
+++ b/src/corelib/thread/qsemaphore.h
@@ -68,7 +68,7 @@ private:
union {
QSemaphorePrivate *d;
- QBasicAtomicInteger<quint32> u;
+ QBasicAtomicInteger<quintptr> u; // ### Qt6: make 64-bit
};
};