diff --git a/lib/pls/include/pls/algorithms/invoke_parallel_impl.h b/lib/pls/include/pls/algorithms/invoke_parallel_impl.h index c2ab998..9bfa185 100644 --- a/lib/pls/include/pls/algorithms/invoke_parallel_impl.h +++ b/lib/pls/include/pls/algorithms/invoke_parallel_impl.h @@ -22,7 +22,7 @@ inline void run_body(const Body &internal_body, const abstract_task::id &id) { if (current_task->unique_id() == id) { internal_body(); } else { - fork_join_lambda_by_reference root_body(&internal_body); + fork_join_lambda_by_reference root_body(internal_body); fork_join_task root_task{&root_body, id}; scheduler::execute_task(root_task); } @@ -36,12 +36,13 @@ void invoke_parallel(const Function1 &function1, const Function2 &function2) { using namespace ::pls::internal::base; static abstract_task::id id = unique_id::create(); - auto internal_body = [&](fork_join_sub_task *this_task) { + auto internal_body = [&]() { + auto current_task = fork_join_sub_task::current(); auto sub_task_2 = fork_join_lambda_by_reference(function2); - this_task->spawn_child(sub_task_2); + current_task->spawn_child(sub_task_2); function1(); // Execute first function 'inline' without spawning a sub_task object - this_task->wait_for_all(); + current_task->wait_for_all(); }; internal::run_body(internal_body, id);