Results 1 to 15 of 15

Thread: A general question about multi-threading (QtConcurrent/QFuture)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    Jun 2007
    Location
    Plymouth, UK
    Posts
    36
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: A general question about multi-threading (QtConcurrent/QFuture)

    I'm sorry but I'm getting lost, Wisota. Your code still generates errors. The line that provoke this behaviour is again the one where you call QtConcurrent::blockingMap(). If I just keep it as you've showed, the compiler tells me that doSomething is not declared in the scope. If I use the syntax QtConcurrent::blockingMap(teamsList, Team::doSomething) instead, the error returned by g++ concerns the use of a non-static member function.

    I'd really like to understand what I'm doing wrong and, overall, what I should do in order to have everything working as expected. I'm perfectly aware that I'm not in the position to ask anything, but if you could please be less cryptic in your replies it would be much easier, quick and helpful to me (as well as less time-wasting to you). Particularly, could I ask you what was wrong with the code that I posted when I opened this thread? And what do you mean exactly when you say "it's C++, not C"?

    Anyhow, let's summarise here the main data structures used by my software, hoping this will help:

    SimulatorEngine is the main class. From here I'd like to run the multi-threaded code.

    SimulatorEngine has a member called teams, pointer to an object belonging to the teamsPopulations class.

    teams contains a member called simTeam, which is an array of pointers to objects belonging to the Team class

    simTeam contains the function performAllTests, which is highly computational-demanding and therefore it's the one I'd like to execute in separate threads. In pseudo-code it would be something like:

    Qt Code:
    1. for currentTeam = 0 -> population size
    2. run teams->simTeam[currentTeam]->performAllTests() in multi-threading (simTeam #1 on thread #1, simTeam #2 on thread #2, and so on...)
    To copy to clipboard, switch view to plain text mode 

    Basically the idea is to evaluate each simTeam in a separate thread, instead that doing everything sequentially. Since the application will run on a dedicated computer cluster, the benefits deriving from this solution should be significant. Of course, if it might make the things easier, I could move from SimulatorEngine to teamsPopulation in order to run simTeam[currentTeam]->performAllTests().

    Many thanks again for your help!
    Last edited by fabietto; 7th September 2009 at 22:56.

Similar Threads

  1. Qt threading question..
    By tgreaves in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2009, 12:00
  2. Newbie question regarding multi platform development
    By bronkopavel in forum Installation and Deployment
    Replies: 2
    Last Post: 15th September 2008, 10:08
  3. Question about threading basics
    By donglebob in forum Qt Programming
    Replies: 8
    Last Post: 29th August 2008, 18:40
  4. General Question about Qt4 Model/View
    By reed in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2008, 15:06
  5. Newbie threading question
    By deepayan in forum Qt Programming
    Replies: 17
    Last Post: 16th April 2007, 00:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.