Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Running a blocking operation with QtConcurrent in case of Qt 5.4?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Running a blocking operation with QtConcurrent in case of Qt 5.4?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • siropS Offline
    siropS Offline
    sirop
    wrote on last edited by sirop
    #1

    Hallo.

    Beg your pardon if my question is stupid.

    I read on http://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html
    that one should not run a blocking operation with QtConcurrent .

    Is this restriction still valid for Qt 5.4 ?

    Thanks in advance for your answers.

    To be, or not to be: that is the question:
    Whether ’tis nobler in the mind to suffer
    The slings and arrows of outrageous fortune,
    Or to take arms against a sea of troubles,
    And by opposing end them?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Leonardo
      wrote on last edited by
      #2

      It really depends on your application. As the guy in the link said, QtConcurrent uses a thread pool. If you need to have many blocking operations running simultaneously, soon you will run out of threads and new requests will be queued. That might not be the desired behavior for some applications, but if you have a single blocking operation and just wants to keep the UI free to show some updates or whatever, I don't see any real problem here.

      siropS 1 Reply Last reply
      0
      • L Leonardo

        It really depends on your application. As the guy in the link said, QtConcurrent uses a thread pool. If you need to have many blocking operations running simultaneously, soon you will run out of threads and new requests will be queued. That might not be the desired behavior for some applications, but if you have a single blocking operation and just wants to keep the UI free to show some updates or whatever, I don't see any real problem here.

        siropS Offline
        siropS Offline
        sirop
        wrote on last edited by
        #3

        @Leonardo said:

        thread pool

        Thanks.

        But why should I not be able to run out of threads if I use more low level QThread
        instead of QtConcurrent?

        To be, or not to be: that is the question:
        Whether ’tis nobler in the mind to suffer
        The slings and arrows of outrageous fortune,
        Or to take arms against a sea of troubles,
        And by opposing end them?

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Leonardo
          wrote on last edited by
          #4

          Because QThread uses no thread pool. It is the thread itself.

          siropS 1 Reply Last reply
          0
          • L Leonardo

            Because QThread uses no thread pool. It is the thread itself.

            siropS Offline
            siropS Offline
            sirop
            wrote on last edited by
            #5

            @Leonardo

            Ok. Thanks.
            I mark the theme as SOLVED.

            To be, or not to be: that is the question:
            Whether ’tis nobler in the mind to suffer
            The slings and arrows of outrageous fortune,
            Or to take arms against a sea of troubles,
            And by opposing end them?

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved