bugfix due to capturing of thread index by reference

This commit is contained in:
Matthias Hochsteger 2016-02-23 11:08:20 +01:00
parent 1b4f596446
commit 402e85cc17

View File

@ -194,11 +194,11 @@ void ParallelFor( int first, int next, const TFunc & f )
int nthreads = thread::hardware_concurrency();
thread * threads = new thread[nthreads];
for (int i=0; i<nthreads; i++)
{
threads[i] = std::thread( [&] ()
{
int myfirst = first + (next-first)*i/nthreads;
int mynext = first + (next-first)*(i+1)/nthreads;
threads[i] = std::thread( [myfirst,mynext,&f] ()
{
f(myfirst, mynext);
});
}