Details
-
Epic
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
-
C++20 threading @ Qt
Description
C++20 added new multi-threading classes:
- std::jthread and std::stop_token (__cpp_lib_jthread, [wg21.link/P0660], [wg21.link/P1869]): thread class that join()'s in the destructor, and a way to cancel threads cooperatively
- Qt already has solutions for these, but we may want to support stop_token in our APIs
- Latches and Barriers (__cpp_lib_latch, [wg21.link/P1135], [wg21.link/P0666]): new threading primitives wrapping semaphores in higher-level concepts
- The usual reflex would be to reimplement these as Qt types, but we shouldn't. If there're enough use-cases to warrant a q20 implementation, we should do that instead
- but solve the problem of missing std::thread and std::future support on MingW first
- The usual reflex would be to reimplement these as Qt types, but we shouldn't. If there're enough use-cases to warrant a q20 implementation, we should do that instead
- Semaphores (__cpp_lib_semaphores, [wg21.link/P1135], [wg21.link/P0514]): Counting semaphore
- Can probably be used to back QSemaphore, removing platform-specific Qt implementation
- benchmark first
- Can probably be used to back QSemaphore, removing platform-specific Qt implementation
- Waiting on every std::atomic (cf. QTBUG-105467)
- First tests show that it's still slower than QMutex
- should investigate why and fix std implementation(s) so we have a fighting chance to get off our own implementation of threading primitives in this decade
- First tests show that it's still slower than QMutex
With the exception of <stop_token>, there appears to be nothing that would affect our APIs.
Attachments
Issue Links
- is required for
-
QTBUG-99243 Initiative: Qt and C++20
- Open
-
QTBUG-109361 C++20 is required for the development and building of Qt itself (Phase II)
- Open
- relates to
-
QTBUG-105467 Impact of C++20 atomics on our code
- Open