From efaf512406c71606d7f05eca10c74510bd9ebc12 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 17 Sep 2012 12:07:06 +0000 Subject: Revert r50528: "Performance fix for Cycles: Don't wait in the main UI thread when resetting devices." This commit leads to random freezes in Cycles rendering: https://projects.blender.org/tracker/index.php?func=detail&aid=32545&group_id=9&atid=498 The goal of this commit was to remove UI lag for OSL, but since that is not officially supported yet, better revert it until a proper fix can be implemented in 2.65. --- intern/cycles/util/util_task.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'intern/cycles/util') diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp index 2b209c135f4..ea0abd6f54f 100644 --- a/intern/cycles/util/util_task.cpp +++ b/intern/cycles/util/util_task.cpp @@ -38,8 +38,6 @@ TaskPool::~TaskPool() void TaskPool::push(Task *task, bool front) { - thread_scoped_lock num_lock(num_mutex); - TaskScheduler::Entry entry; entry.task = task; @@ -104,17 +102,22 @@ void TaskPool::wait_work() void TaskPool::cancel() { - thread_scoped_lock num_lock(num_mutex); - do_cancel = true; TaskScheduler::clear(this); + + { + thread_scoped_lock num_lock(num_mutex); + + while(num) + num_cond.wait(num_lock); + } + + do_cancel = false; } void TaskPool::stop() { - thread_scoped_lock num_lock(num_mutex); - TaskScheduler::clear(this); assert(num == 0); @@ -127,20 +130,20 @@ bool TaskPool::cancelled() void TaskPool::num_decrease(int done) { + num_mutex.lock(); num -= done; + assert(num >= 0); - - if(num == 0) { - do_cancel = false; - + if(num == 0) num_cond.notify_all(); - } + + num_mutex.unlock(); } void TaskPool::num_increase() { + thread_scoped_lock num_lock(num_mutex); num++; - num_cond.notify_all(); } @@ -236,11 +239,7 @@ void TaskScheduler::thread_run(int thread_id) delete entry.task; /* notify pool task was done */ - { - /* not called from TaskPool, have to explicitly lock the mutex here */ - thread_scoped_lock num_lock(entry.pool->num_mutex); - entry.pool->num_decrease(1); - } + entry.pool->num_decrease(1); } } -- cgit v1.2.3