From 1d2cee2ab00f9b9a7b1e526e0fdd4062e3b0576f Mon Sep 17 00:00:00 2001 From: Sven Woop Date: Wed, 22 Apr 2015 13:57:51 +0200 Subject: [PATCH] fixed raise condition in taskscheduler_new --- common/tasking/taskscheduler_new.cpp | 17 +++++++++-------- common/tasking/taskscheduler_new.h | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/common/tasking/taskscheduler_new.cpp b/common/tasking/taskscheduler_new.cpp index c25fdb092e..930cdbbd38 100644 --- a/common/tasking/taskscheduler_new.cpp +++ b/common/tasking/taskscheduler_new.cpp @@ -119,7 +119,7 @@ namespace embree TaskSchedulerNew::TaskSchedulerNew(size_t numThreads, bool spinning) : threadCounter(numThreads), createThreads(true), terminate(false), anyTasksRunning(0), active(false), spinning(spinning), - task_set_function(nullptr) + task_set_function(nullptr), masterThread(0,this) { for (size_t i=0; i 0; }, @@ -407,26 +407,27 @@ namespace embree for (size_t i=0; itasks.steal(thread)) + if (othread->tasks.steal(thread)) return true; } /* nothing found this time, do another round */ #else for (size_t i=1; i= threadCount) otherThreadIndex -= threadCount; - if (!threadLocal[otherThreadIndex]) + Thread* othread = threadLocal[otherThreadIndex]; + if (!othread) continue; - - if (threadLocal[otherThreadIndex]->tasks.steal(thread)) + + if (othread->tasks.steal(thread)) return true; } #endif diff --git a/common/tasking/taskscheduler_new.h b/common/tasking/taskscheduler_new.h index f7ea458147..c3e770d0c6 100644 --- a/common/tasking/taskscheduler_new.h +++ b/common/tasking/taskscheduler_new.h @@ -246,7 +246,7 @@ namespace embree assert(!active); active = true; - Thread thread(0,this); + Thread& thread = masterThread; threadLocal[0] = &thread; setThread(&thread); thread.tasks.push_right(thread,size,closure); @@ -274,7 +274,7 @@ namespace embree assert(!active); active = true; - Thread thread(0,this); + Thread& thread = masterThread; threadLocal[0] = &thread; setThread(&thread); @@ -376,6 +376,7 @@ namespace embree __dllexport2 static TaskSchedulerNew* global_instance(); private: + Thread masterThread; static TaskSchedulerNew* g_instance; static __thread Thread* thread_local_thread;