path: root/config.tests
diff options
authorVolker Hilsheimer <>2019-08-19 13:33:31 +0200
committerVolker Hilsheimer <>2019-10-20 17:08:57 +0200
commit5e9b2ade678f37e43bfc2e3484f54cbbb5844d2e (patch)
tree6415a35c0a3bb9a2ca0f3e62e126986fb30c83a6 /config.tests
parentab5153aa0b09320dc5c96aa2b5a564ea1e6dbed3 (diff)
Read a unique thread identifier from CPU registers
This is, depending on the implementation of pthread, significantly cheaper than using a pthread library call. Even if we don't know the assembler for an architecture, taking the address of the thread_local variable is still faster. As QThread::currentThreadId() is documented to be used internally and not meant for application code, we don't have to care about what exact value we return. Internally, we use it only to compare thread IDs for equality, which this implementation is sufficient for, even if a thread ID is re-used when one of the threads terminate and a new thread starts (since the other thread is still executing code). Besides, pthread_self documents [0] that a thread ID may be reused, and that the returned pthread_t cannot be portably compared using operator==(); using pthread_equal would require adding a Qt thread-ID type that implements this correctly, and would make things even slower. [0] Change-Id: Id08e79b9b9c88976561f7cd36c66d43771fc4f24 Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'config.tests')
0 files changed, 0 insertions, 0 deletions