diff --git a/source/blender/blenlib/intern/task_pool.cc b/source/blender/blenlib/intern/task_pool.cc index 6404f5264cc..a397e30e6ea 100644 --- a/source/blender/blenlib/intern/task_pool.cc +++ b/source/blender/blenlib/intern/task_pool.cc @@ -115,6 +115,7 @@ class Task { void operator()() const { #ifdef WITH_TBB + // run(pool, taskdata); tbb::this_task_arena::isolate([this] { run(pool, taskdata); }); #else run(pool, taskdata); diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc index 1ad3fdbc9da..3cf989f12d5 100644 --- a/source/blender/depsgraph/intern/depsgraph_eval.cc +++ b/source/blender/depsgraph/intern/depsgraph_eval.cc @@ -45,8 +45,42 @@ #include "intern/depsgraph.h" +#include "BLI_task.h" +#include "PIL_time.h" + namespace deg = blender::deg; +static void empty_subtask(TaskPool *UNUSED(pool), void *UNUSED(taskdata)) +{ +} + +static void pushing_subtask(TaskPool *pool, void *UNUSED(taskdata)) +{ + for (int i = 0; i < 100; i++) { + BLI_task_pool_push(pool, empty_subtask, nullptr, false, nullptr); + } +} + +static void my_task(TaskPool *UNUSED(pool), void *UNUSED(taskdata)) +{ + TaskPool *task_pool = BLI_task_pool_create(nullptr, TASK_PRIORITY_HIGH); + BLI_task_pool_push(task_pool, pushing_subtask, POINTER_FROM_INT(1), false, nullptr); + BLI_task_pool_work_and_wait(task_pool); + BLI_task_pool_free(task_pool); +} + +static void my_test() +{ + const int num_tasks = BLI_system_thread_count() * 2; + + TaskPool *task_pool = BLI_task_pool_create(nullptr, TASK_PRIORITY_HIGH); + for (int i = 0; i < num_tasks; i++) { + BLI_task_pool_push(task_pool, my_task, nullptr, false, nullptr); + } + BLI_task_pool_work_and_wait(task_pool); + BLI_task_pool_free(task_pool); +} + static void deg_flush_updates_and_refresh(deg::Depsgraph *deg_graph) { /* Update the time on the cow scene. */ @@ -56,6 +90,10 @@ static void deg_flush_updates_and_refresh(deg::Depsgraph *deg_graph) deg::deg_graph_flush_updates(deg_graph); deg::deg_evaluate_on_refresh(deg_graph); + + std::cout << "Start test\n"; + my_test(); + std::cout << "End test\n"; } /* Evaluate all nodes tagged for updating. */