Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,13 @@ end
## hook for disabling threaded libraries ##

library_threading_enabled::Bool = true
const disable_library_threading_hooks = []

# Base.OncePerProcess ensures that any registered hooks do not outlive the session.
# (even if they are registered during the sysimage build process by top-level code)
const disable_library_threading_hooks = Base.OncePerProcess(Vector{Any})

function at_disable_library_threading(f)
push!(disable_library_threading_hooks, f)
push!(disable_library_threading_hooks(), f)
if !library_threading_enabled
disable_library_threading()
end
Expand All @@ -506,8 +509,8 @@ end

function disable_library_threading()
global library_threading_enabled = false
while !isempty(disable_library_threading_hooks)
f = pop!(disable_library_threading_hooks)
while !isempty(disable_library_threading_hooks())
f = pop!(disable_library_threading_hooks())
try
f()
catch err
Expand Down