From 633fee72d5cb4c1f3136781561a72deb301a44d7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 9 May 2020 17:01:40 +0200 Subject: Fix T76427: edit mesh undo hanges when building without TBB Background task pools would not restart threads if reused multiple times, thanks to Jeroen for identifying the cause of this problem. Differential Revision: https://developer.blender.org/D7659 --- source/blender/blenlib/intern/task_pool.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/blenlib/intern/task_pool.cc') diff --git a/source/blender/blenlib/intern/task_pool.cc b/source/blender/blenlib/intern/task_pool.cc index d8e90af551a..c4d60673492 100644 --- a/source/blender/blenlib/intern/task_pool.cc +++ b/source/blender/blenlib/intern/task_pool.cc @@ -305,7 +305,6 @@ static void background_task_pool_create(TaskPool *pool) { pool->background_queue = BLI_thread_queue_init(); BLI_threadpool_init(&pool->background_threads, background_task_run, 1); - BLI_threadpool_insert(&pool->background_threads, pool); } static void background_task_pool_run(TaskPool *pool, Task &&task) @@ -313,6 +312,10 @@ static void background_task_pool_run(TaskPool *pool, Task &&task) Task *task_mem = (Task *)MEM_mallocN(sizeof(Task), __func__); new (task_mem) Task(std::move(task)); BLI_thread_queue_push(pool->background_queue, task_mem); + + if (BLI_available_threads(&pool->background_threads)) { + BLI_threadpool_insert(&pool->background_threads, pool); + } } static void background_task_pool_work_and_wait(TaskPool *pool) @@ -321,7 +324,7 @@ static void background_task_pool_work_and_wait(TaskPool *pool) * left, and wait for tasks and thread to finish. */ BLI_thread_queue_nowait(pool->background_queue); BLI_thread_queue_wait_finish(pool->background_queue); - BLI_threadpool_remove(&pool->background_threads, pool); + BLI_threadpool_clear(&pool->background_threads); } static void background_task_pool_cancel(TaskPool *pool) -- cgit v1.2.3