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:
for currentTeam = 0 -> population size
run teams->simTeam[currentTeam]->performAllTests() in multi-threading (simTeam #1 on thread #1, simTeam #2 on thread #2, and so on...)
for currentTeam = 0 -> population size
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!
Bookmarks