Skip to content

Commit 9a60001

Browse files
committed
Make some global variables constant
1 parent ed87f07 commit 9a60001

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Sandbox.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ include("Docker.jl")
5151
# Load the UserNamespace executor
5252
include("UserNamespaces.jl")
5353

54-
all_executors = Type{<:SandboxExecutor}[
54+
const all_executors = Type{<:SandboxExecutor}[
5555
# We always prefer the UserNamespaces executor, if we can use it,
5656
# and the unprivileged one most of all. Only after that do we try `docker`.
5757
UnprivilegedUserNamespacesExecutor,
@@ -89,16 +89,15 @@ function select_executor(verbose::Bool)
8989
error("Could not find any available executors for $(triplet(HostPlatform()))!")
9090
end
9191

92-
_preferred_executor = nothing
92+
const _preferred_executor = Ref{Union{Nothing, (x->Type{x}).(Sandbox.all_executors)...}}(nothing)
9393
const _preferred_executor_lock = ReentrantLock()
9494
function preferred_executor(;verbose::Bool = false)
9595
lock(_preferred_executor_lock) do
9696
# 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)
10099
end
101-
return _preferred_executor
100+
return _preferred_executor[]
102101
end
103102
end
104103

0 commit comments

Comments
 (0)