memory bug fixes
This commit is contained in:
@ -12,8 +12,8 @@ namespace imglib4
|
||||
template<typename callable, typename ... argst> int threaded_execute(callable &&fptr, int64_t psize, argst&&... args)
|
||||
{
|
||||
int ret = amsimage_success;
|
||||
int nthreads;
|
||||
int I;
|
||||
int nthreads = 1;
|
||||
int I = 0;
|
||||
std::vector<std::thread*> threads;
|
||||
|
||||
if(psize<amsimage_threadpsz)
|
||||
@ -28,6 +28,14 @@ template<typename callable, typename ... argst> int threaded_execute(callable &&
|
||||
nthreads = (nthreads<=0) ? 1 : nthreads;
|
||||
nthreads = (nthreads>amsimage_maxthreads) ? amsimage_maxthreads : nthreads;
|
||||
threads.resize(nthreads);
|
||||
if(threads.size()!=nthreads)
|
||||
{
|
||||
//fallback to single threaded execution
|
||||
nthreads = 1;
|
||||
I = 0;
|
||||
fptr(I,nthreads,std::forward<argst>(args)...);
|
||||
return amsimage_success;
|
||||
}
|
||||
for(I=0;I<nthreads;I++) threads[I] = NULL;
|
||||
for(I=0;I<nthreads;I++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user