From 11fd34cc1c398f2c2311339ed3b008b1114544eb Mon Sep 17 00:00:00 2001 From: William Kong Date: Wed, 9 Apr 2025 17:21:36 +0000 Subject: [PATCH] Fix the typing of the Tasks in ForkJoin.h --- Eigen/src/ThreadPool/ForkJoin.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Eigen/src/ThreadPool/ForkJoin.h b/Eigen/src/ThreadPool/ForkJoin.h index 233d2837a..588636a6c 100644 --- a/Eigen/src/ThreadPool/ForkJoin.h +++ b/Eigen/src/ThreadPool/ForkJoin.h @@ -76,7 +76,7 @@ class ForkJoinScheduler { } // Synchronous variant of ParallelForAsync. - // WARNING: Making nested calls to `ParallelFor`, e.g., calling `ParallelFor` inside a task passed into another + // WARNING: Making nested calls to `ParallelFor`, e.g., calling `ParallelFor` inside a task passed into another // `ParallelFor` call, may lead to deadlocks due to how task stealing is implemented. template static void ParallelFor(Index start, Index end, Index granularity, DoFnType&& do_func, @@ -92,6 +92,7 @@ class ForkJoinScheduler { // Schedules `right_thunk`, runs `left_thunk`, and runs other tasks until `right_thunk` has finished. template static void ForkJoin(LeftType&& left_thunk, RightType&& right_thunk, ThreadPoolTempl* thread_pool) { + typedef typename ThreadPoolTempl::Task Task; std::atomic right_done(false); auto execute_right = [&right_thunk, &right_done]() { std::forward(right_thunk)(); @@ -99,7 +100,7 @@ class ForkJoinScheduler { }; thread_pool->Schedule(execute_right); std::forward(left_thunk)(); - ThreadPool::Task task; + Task task; while (!right_done.load(std::memory_order_acquire)) { thread_pool->MaybeGetTask(&task); if (task.f) task.f();