Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-108781

Impact of C++20 multi-threading library additions on our code



    • Epic
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • None
    • Core: Threads
    • None
    • C++20 threading @ Qt


      C++20 added new multi-threading classes:

      1. 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
      2. 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
      3. 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
      4. 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

      With the exception of <stop_token>, there appears to be nothing that would affect our APIs.


        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.



              cnn Qt Core & Network
              mmutz Marc Mutz
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              0 Vote for this issue
              3 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes