Threads still running after QFuture waitForFinished



  • A simple Windows 7 QT5.7 console project with no QCoreApplication has the following code in it:

    QFuture<void > f = QtConcurrent::mapped(list ,function);
    f.waitForFinished();
    exit(0);

    This results in an error message per core on the console:

    QWaitCondition: Destroyed while threads are still waiting
    QWaitCondition: Destroyed while threads are still waiting
    QWaitCondition: Destroyed while threads are still waiting
    QWaitCondition: Destroyed while threads are still waiting

    Shouldn't f.waitForFinished() ensure that the threads created have terminated? They seem to hang around for a long time, until the program runs a new QtConcurrent::mapped


  • Qt Champions 2016

    @ktwolff
    Hello,

    exit(0);
    

    why???!!!

    Shouldn't f.waitForFinished() ensure that the threads created have terminated?

    No, it ensures your job has finished. The QtConcurrent module manages a thread pool that will be initialized or deinitialized when the module deems fit (on startup/shutdown).

    Kind regards.



  • @kshegunov Many thanks!

    I placed an exit in my code debugging something and I was curious...

    • Ken

  • Qt Champions 2016

    @ktwolff

    I placed an exit in my code debugging something and I was curious...

    Well that's the reason for getting the warnings, as exit is really notorious way to quit the application. Long story - short, one shouldn't use it, save for exceptional circumstances.

    Kind regards.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.