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

Threads still running after QFuture waitForFinished

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfuture
4 Posts 2 Posters 1.9k 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.
  • ktwolffK Offline
    ktwolffK Offline
    ktwolff
    wrote on 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

    kshegunovK 1 Reply Last reply
    0
    • ktwolffK ktwolff

      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

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on 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

      ktwolffK 1 Reply Last reply
      0
      • kshegunovK kshegunov

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

        ktwolffK Offline
        ktwolffK Offline
        ktwolff
        wrote on last edited by
        #3

        @kshegunov Many thanks!

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

        • Ken
        kshegunovK 1 Reply Last reply
        0
        • ktwolffK ktwolff

          @kshegunov Many thanks!

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

          • Ken
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on 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

          • Login

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