Skip to content

Commit

Permalink
Rename atexit_hooks_lock
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed May 11, 2023
1 parent a60d49a commit 98d72e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ end
const atexit_hooks = Callable[
() -> Filesystem.temp_cleanup_purge(force=true)
]
const _atexit_lock = ReentrantLock()
const _atexit_hooks_lock = ReentrantLock()

"""
atexit(f)
Expand All @@ -375,7 +375,7 @@ calls `exit(n)`, then Julia will exit with the exit code corresponding to the
last called exit hook that calls `exit(n)`. (Because exit hooks are called in
LIFO order, "last called" is equivalent to "first registered".)
"""
atexit(f::Function) = Base.@lock _atexit_lock (pushfirst!(atexit_hooks, f); nothing)
atexit(f::Function) = Base.@lock _atexit_hooks_lock (pushfirst!(atexit_hooks, f); nothing)

function _atexit(exitcode::Cint)
while !isempty(atexit_hooks)
Expand Down
2 changes: 1 addition & 1 deletion test/threads_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ end
@test all(hook -> hook === f, Base.atexit_hooks[1 : 1_000_000])

# cleanup
Base.@lock Base._atexit_lock begin
Base.@lock Base._atexit_hooks_lock begin
deleteat!(Base.atexit_hooks, 1:1_000_000)
end
end
Expand Down

0 comments on commit 98d72e8

Please sign in to comment.