Skip to content

Commit 6598a1a

Browse files
committed
Don't manually disable finalizers before locking.
This is already done by Base.
1 parent 83d44d3 commit 6598a1a

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

lib/utils/cache.jl

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@ end
1717
# remove a handle from the cache, or create a new one
1818
function Base.pop!(f::Function, cache::HandleCache{K,V}, key) where {K,V}
1919
function check_cache(f::Function=()->nothing)
20-
try
21-
GC.enable_finalizers(false)
22-
lock(cache.lock) do
23-
handle = if !haskey(cache.idle_handles, key) || isempty(cache.idle_handles[key])
24-
f()
25-
else
26-
pop!(cache.idle_handles[key])
27-
end
28-
29-
if handle !== nothing
30-
push!(cache.active_handles, key=>handle)
31-
end
20+
lock(cache.lock) do
21+
handle = if !haskey(cache.idle_handles, key) || isempty(cache.idle_handles[key])
22+
f()
23+
else
24+
pop!(cache.idle_handles[key])
25+
end
3226

33-
return handle
27+
if handle !== nothing
28+
push!(cache.active_handles, key=>handle)
3429
end
35-
finally
36-
GC.enable_finalizers(true)
30+
31+
return handle
3732
end
3833
end
3934

0 commit comments

Comments
 (0)