I have a code like this with function double myfunction(double)
that takes a lot of time to finish.
Using Qt (https://doc.qt.io/qt-5/qtconcurrentrun.html), how can I run the loop utilizing a thread for every myfunction
call to have smaller computation time? Does this make sense?
std::vector<double> parameters; //vector full of input values
std::vector<double> results; //vector to store results in
for(uint i=0; i<parameters.size(); i++)
{
double parameter = parameters.at(i);
double result = myfunction(parameter);
results.push_back(result);
}
A simple example usage of
QtConcurrent::run
for you own case would be something like (untested)...