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. Threads still running after QFuture waitForFinished
QtWS25 Last Chance

Threads still running after QFuture waitForFinished

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfuture
4 Posts 2 Posters 1.8k 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.
  • K Offline
    K Offline
    ktwolff
    wrote on 26 Jul 2016, 20:45 last edited by
    #1

    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

    K 1 Reply Last reply 26 Jul 2016, 21:30
    0
    • K ktwolff
      26 Jul 2016, 20:45

      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

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 26 Jul 2016, 21:30 last edited by
      #2

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

      Read and abide by the Qt Code of Conduct

      K 1 Reply Last reply 26 Jul 2016, 21:53
      0
      • K kshegunov
        26 Jul 2016, 21:30

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

        K Offline
        K Offline
        ktwolff
        wrote on 26 Jul 2016, 21:53 last edited by
        #3

        @kshegunov Many thanks!

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

        • Ken
        K 1 Reply Last reply 26 Jul 2016, 22:03
        0
        • K ktwolff
          26 Jul 2016, 21:53

          @kshegunov Many thanks!

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

          • Ken
          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 26 Jul 2016, 22:03 last edited by
          #4

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

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          1/4

          26 Jul 2016, 20:45

          • Login

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