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

Provide "fluent interface" for QtConcurrent::run

    XMLWordPrintable

Details

    • User Story
    • Resolution: Done
    • P2: Important
    • 6.0
    • 6.0
    • Core: QtConcurrent
    • None
    • All
    • 13
    • Qt6_Foundation_ Sprint 5
    • 5a0d4f3313157d2fe48e9d159968bed6883eb5f8

    Description

      QtConcurrent::run provides an API for running a callable object in a separate thread. This functionality is represented by a few functions with different signatures. One of the functions allows a user to specify a thread pool on which the task should be executed.

      There are a few requests from Qt users regarding adding more parameters to the API. For example, set a priority for a task.

      Adding more parameters leads to increasing API complexity. Furthermore, some of parameters are not mandatory. For example, it should be possible to set a priority for a task, but not specify a thread pool.

      In light of this, it would be nice to have a fluent interface for adjusting some related parameters. It should also improve code readability.

      Example of a such interface (all calls between "task" and "spawn" are optional):

      QtConcurrent::task(doSmth)
          .withArguments(1, 2, 3)
          .onThreadPool(pool)
          .withPriority(10)
          .spawn() // Returns a future object
          .waitForFinished();
      

      Attachments

        Issue Links

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

          Activity

            People

              vitaly.fanaskov Vitaly Fanaskov
              vitaly.fanaskov Vitaly Fanaskov
              Maurice Kalinowski Maurice Kalinowski
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes