Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-05-10 16:43:03 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-05-10 16:43:03 +0300
commit335274192e3d6c78e58ad2123dbdb7a384f3988b (patch)
tree5f3fefe4262751137e0bec1863102bd408bf11cf /source/blender/blenlib/intern/task.c
parentf501dfb085557038679e40c9d5501ebe33db4aee (diff)
Revert "Task scheduler: Avoid mutex lock in number manipulation functions"
Appears mutex was guarateeing number of tasks is not modified at moments when it's not expected. Removing those mutexes resulted in some hard-to-catch locks where worker thread were waiting for work by all the tasks were already done. This reverts commit a1d8fe052ccd8945f14be5a50bd5af581b89c643.
Diffstat (limited to 'source/blender/blenlib/intern/task.c')
-rw-r--r--source/blender/blenlib/intern/task.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index a62ba734a3c..b47931cdde9 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -230,21 +230,28 @@ static void task_free(TaskPool *pool, Task *task, const int thread_id)
static void task_pool_num_decrease(TaskPool *pool, size_t done)
{
+ BLI_mutex_lock(&pool->num_mutex);
+
BLI_assert(pool->num >= done);
- atomic_sub_z((size_t*)&pool->num, done);
+ pool->num -= done;
atomic_sub_z(&pool->currently_running_tasks, done);
- atomic_add_z((size_t*)&pool->done, done);
+ pool->done += done;
- if (pool->num == 0) {
+ if (pool->num == 0)
BLI_condition_notify_all(&pool->num_cond);
- }
+
+ BLI_mutex_unlock(&pool->num_mutex);
}
static void task_pool_num_increase(TaskPool *pool)
{
- atomic_add_z((size_t*)&pool->num, 1);
+ BLI_mutex_lock(&pool->num_mutex);
+
+ pool->num++;
BLI_condition_notify_all(&pool->num_cond);
+
+ BLI_mutex_unlock(&pool->num_mutex);
}
static bool task_scheduler_thread_wait_pop(TaskScheduler *scheduler, Task **task)