@@ -119,7 +119,7 @@ namespace embree
119
119
120
120
TaskSchedulerNew::TaskSchedulerNew (size_t numThreads, bool spinning)
121
121
: threadCounter(numThreads), createThreads(true ), terminate(false ), anyTasksRunning(0 ), active(false ), spinning(spinning),
122
- task_set_function (nullptr )
122
+ task_set_function (nullptr ), masterThread( 0 , this )
123
123
{
124
124
for (size_t i=0 ; i<MAX_THREADS; i++)
125
125
threadLocal[i] = NULL ;
@@ -317,7 +317,7 @@ namespace embree
317
317
if (executeTaskSet (thread))
318
318
continue ;
319
319
#endif
320
-
320
+
321
321
/* work on available task */
322
322
steal_loop (thread,
323
323
[&] () { return anyTasksRunning > 0 ; },
@@ -407,26 +407,27 @@ namespace embree
407
407
for (size_t i=0 ; i<workingThreads; i++)
408
408
{
409
409
const size_t otherThreadIndex = thread_task_size[i].second ;
410
- if (!threadLocal[otherThreadIndex])
410
+ Thread* othread = threadLocal[otherThreadIndex];
411
+ if (!othread)
411
412
continue ;
412
413
413
- if (threadLocal[otherThreadIndex] ->tasks .steal (thread))
414
+ if (othread ->tasks .steal (thread))
414
415
return true ;
415
416
}
416
417
/* nothing found this time, do another round */
417
418
418
419
#else
419
420
for (size_t i=1 ; i<threadCount; i++)
420
- // for (size_t i=1; i<32; i++)
421
421
{
422
422
__pause_cpu (32 );
423
423
size_t otherThreadIndex = threadIndex+i;
424
424
if (otherThreadIndex >= threadCount) otherThreadIndex -= threadCount;
425
425
426
- if (!threadLocal[otherThreadIndex])
426
+ Thread* othread = threadLocal[otherThreadIndex];
427
+ if (!othread)
427
428
continue ;
428
-
429
- if (threadLocal[otherThreadIndex] ->tasks .steal (thread))
429
+
430
+ if (othread ->tasks .steal (thread))
430
431
return true ;
431
432
}
432
433
#endif
0 commit comments