I have a for-loop that will run a fixed number of times, usually in the 100-300 range depending on the input. Every iteration of this loop calls a function that I want to be threaded. The function to thread grabs data from an input file, does some stuff with it, then writes it out in a new format to an output file...
Here is some high-level code:
void myClass::processFile()
{
...
for (int index = 0; index < 200; index++)
{
//Function or loop to thread
generateData(someMapOfMaps1[index], someMapOfMaps2[index]);
}
}
Then inside generateData within the same class:
void myClass::generateData(QMap<float, foo*> mapA, QMap<float, foo*> mapB)
{
//read in data from a file
//process data
//write data to a different file
}
I played around with QtConcurrent::run()
and QtConcurrent::mapped()
but didn't have much luck. I believe mapped()
would have been a great choice, but my function takes 2 maps instead of just one.
I was using this as a resource, around slide 25: http://www.develer.com/promo/workshop/enhancing_with_multi_threading.pdf
Thanks!