@@ -51,7 +51,7 @@ include("Docker.jl")
51
51
# Load the UserNamespace executor
52
52
include (" UserNamespaces.jl" )
53
53
54
- all_executors = Type{<: SandboxExecutor }[
54
+ const all_executors = Type{<: SandboxExecutor }[
55
55
# We always prefer the UserNamespaces executor, if we can use it,
56
56
# and the unprivileged one most of all. Only after that do we try `docker`.
57
57
UnprivilegedUserNamespacesExecutor,
@@ -89,16 +89,15 @@ function select_executor(verbose::Bool)
89
89
error (" Could not find any available executors for $(triplet (HostPlatform ())) !" )
90
90
end
91
91
92
- _preferred_executor = nothing
92
+ const _preferred_executor = Ref {Union{Nothing, (x->Type{x}).(all_executors)...}} ( nothing )
93
93
const _preferred_executor_lock = ReentrantLock ()
94
94
function preferred_executor (;verbose:: Bool = false )
95
95
lock (_preferred_executor_lock) do
96
96
# If we've already asked this question, return the old answer
97
- global _preferred_executor
98
- if _preferred_executor === nothing
99
- _preferred_executor = select_executor (verbose)
97
+ if _preferred_executor[] === nothing
98
+ _preferred_executor[] = select_executor (verbose)
100
99
end
101
- return _preferred_executor
100
+ return _preferred_executor[]
102
101
end
103
102
end
104
103
0 commit comments