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 waitingShouldn'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
-
@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.
-
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.