From 6fd2d836b9e8071db14d2dcfc45269e9497b4bfe Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Wed, 21 May 2025 13:23:21 +0200 Subject: [PATCH] Add function `reinit_task` --- src/threadtasks.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/threadtasks.jl b/src/threadtasks.jl index 668ed31..43dae15 100644 --- a/src/threadtasks.jl +++ b/src/threadtasks.jl @@ -76,6 +76,17 @@ end yield() false end + +# Like checktask, but without throwing errors. +# This is used in Polyester.reset_threads!(). +@noinline function reinit_task(tid) + t = TASKS[tid] + if istaskfailed(t) + initialize_task(tid) + end + yield() +end + # 1-based tid @inline tasktid(p::Ptr{UInt}) = (p - THREADPOOLPTR[]) รท (THREADBUFFERSIZE) @inline wait(tid::Integer) = wait(taskpointer(tid), tid)