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. What is the maximum number of QFuture<> :: QtConcurrent::run() can I create?
Forum Update on Monday, May 27th 2025

What is the maximum number of QFuture<> :: QtConcurrent::run() can I create?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • S Offline
    S Offline
    scottnat
    wrote on last edited by
    #1

    Hi guys. I have an application that reads and processes data in separate threads using QFuture and QtConcurrent run. Also I have some other questions I hope to discuss with you guys. Thanks!

    Q1) Would continuously creating multiple QFutures be an issue?

    • When work is finish, create another QFuture with some bools as a control.
    • As seen from the rough draft below of how my programme works.
    • Why I am asking this, is because every now and then, the results from my worker class returns me "wrong results." I also suspect that the main thread is causing interruptions in the QFuture thread?

    Q2) What is the difference in running applications with the debugger (CDB) as compared to executing the application without debugger?

    • Why I am asking this? Because when I run my application in debugger, I get "correct results". Whereas in debug/release, I think some of the functions or steps are skipped along the way, producing those "wrong results".
    //connect signals&slots
    connect(  &myClassObj, &myClass::WORKFINISH(int) , &this, &MainWindow::slot_work_done(int) );
    
    //the main gist of the programme in MainWindow
    
    READY = true;
    
    while(1){
      double* buffer = new double[1000]; //data
      fillBuffer(buffer);  //function to fill the data
      if(READY){
         QFuture<void> futureOb = QtConcurrent::run( &myClassObject, &myClass::PROCESSdata, buffer); //do i need to handle destruction of this? 
          READY = false; //will not invoke another QFuture till current QFuture is done
      }
      delete [] buffer;
    }
    
    void MainWindow::slot_work_done(int x){
       ... //display results etc
       READY = true;
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From the looks of it, you'll be deleting buffer before it's processed. You should release it once you know the processing has been done so in PROCESSdata.

      By the way, why use QtConcurrent, if you only one want one PROCESSdata call at a time ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      3
      • SGaistS SGaist

        Hi,

        From the looks of it, you'll be deleting buffer before it's processed. You should release it once you know the processing has been done so in PROCESSdata.

        By the way, why use QtConcurrent, if you only one want one PROCESSdata call at a time ?

        S Offline
        S Offline
        scottnat
        wrote on last edited by
        #3

        @SGaist Hi SGaist, I am using QtConcurrent because the PROCESSdata takes anywhere between 2 to 15 seconds. It comprises of FFTs and other time consuming algorithms.

        Ah, the buffer is deleted before process. I will give it a fix. Thanks.

        However, with regards to why debugging mode produces different results. Do you have any ideas?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Not the same way to initialise variables.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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