Skip to content

Commit

Permalink
fix #52, bad ccall with julia v1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 30, 2021
1 parent f62e3ec commit 048d1cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ end

Base.unlock(nrl::NonReentrantLock) = unlock(nrl.rl)

if VERSION >= v"1.7.0-DEV"
# as of v1.7 locks in Base disable finalizers
enable_finalizers(on::Bool) = nothing
else
# NonReentrantLock may be taken around code that might call the GC, which might
# reenter through finalizers. Avoid that by temporarily disabling finalizers
# running concurrently on this thread.
enable_finalizers(on::Bool) = ccall(:jl_gc_enable_finalizers, Cvoid,
(Ptr{Cvoid}, Int32,), Core.getptls(), on)
end

macro safe_lock(l, ex)
quote
temp = $(esc(l))
Expand Down

0 comments on commit 048d1cc

Please sign in to comment.