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. FutureWatcher is never finished for QtConcurent::MappedReduced as last thread is suspended
Qt 6.11 is out! See what's new in the release blog

FutureWatcher is never finished for QtConcurent::MappedReduced as last thread is suspended

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 384 Views
  • 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.
  • D Offline
    D Offline
    dbill
    wrote on last edited by
    #1

    Hello,

    I am currently facing a strange behavior trying to use QtConcurrent::MappedReduced to dispatch some intensive work on threads.

    In fact I store up to 300 input data into a QVector, call QtConcurrent::MappedReduced(unordered) to execute the same computation on these data and wait for the reduced result using QFutureWatcher.

    Every thing is correct for the 299 first computations but when it comes to the last one, the thread dedicated to this computation is stuck on some method of one of my classes; and QFutureWatcher is endlessly waiting for the multithreaded computation to finish.

    Depending on the run, the thread which does not terminate is not always the same (i.e. the input data is not the always the same) but there is always one thread which does not terminate at the end of concurrent computation, blocking the application forever.

    I can see into the traces that the number of working threads in the QThreadPool is initially set to 8 (i.e. the ideal number of threads in the pool considering the 8 cores of the CPU) until the end of concurrent computation where this number is smoothly decreasing down to 1 (but never to 0 alas).

    When I am looking into the stack of the suspended thread, I can see that this thread is trying to delete some QSharedPointer but it seems that it fails to do so as it is stuck there.

    0e924d02-2239-4024-80aa-2021686d6e6b-image.png

    Seems to me that my problem is related to the managment of QSharedPointer in QThread.

    I am using QtCreator 3.4.1 and Qt 5.5.1 which is not the mots up-to-date environment but OK it should work nevertheless.

    I have asked my friend google trying to find someone who may have encounter the same kind of problem, in vain.

    Does anyone have an idea about the reason why my application is stuck waiting to delete some QSharedPointer ?

    Thank you for your attention.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      I see in your call stack that you are executing a method via QtConcurrent, the lifetime of the object hosting said function might be the coulprit here.
      Can you tell us what is your concurrent function calling on each item in the vector?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      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