Skip to content

Commit 6f0ea0f

Browse files
committed
fix #32970, at-threads disabled after a loop errors
1 parent 050160c commit 6f0ea0f

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

base/threadingconstructs.jl

+2-9
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ on `threadid()`.
1818
"""
1919
nthreads() = Int(unsafe_load(cglobal(:jl_n_threads, Cint)))
2020

21-
# Only read/written by the main thread
22-
const in_threaded_loop = Ref(false)
23-
2421
function _threadsfor(iter,lbody)
2522
lidx = iter.args[1] # index
2623
range = iter.args[2]
@@ -65,15 +62,11 @@ function _threadsfor(iter,lbody)
6562
end
6663
end
6764
end
68-
# Hack to make nested threaded loops kinda work
69-
if threadid() != 1 || in_threaded_loop[]
70-
# We are in a nested threaded loop
65+
if threadid() != 1
66+
# only thread 1 can enter/exit _threadedregion
7167
Base.invokelatest(threadsfor_fun, true)
7268
else
73-
in_threaded_loop[] = true
74-
# the ccall is not expected to throw
7569
ccall(:jl_threading_run, Cvoid, (Any,), threadsfor_fun)
76-
in_threaded_loop[] = false
7770
end
7871
nothing
7972
end

0 commit comments

Comments
 (0)