Skip to content

Commit 59864d5

Browse files
committed
Remove default impl of assert_havelock; add ::SpinLock impl
1 parent 9745986 commit 59864d5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

base/condition.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ function trylock end
2222
function islocked end
2323
unlockall(l::AbstractLock) = unlock(l) # internal function for implementing `wait`
2424
relockall(l::AbstractLock, token::Nothing) = lock(l) # internal function for implementing `wait`
25-
assert_havelock(l::AbstractLock) = assert_havelock(l, Threads.threadid())
2625
assert_havelock(l::AbstractLock, tid::Integer) =
2726
(islocked(l) && tid == Threads.threadid()) ? nothing : concurrency_violation()
2827
assert_havelock(l::AbstractLock, tid::Task) =

base/locks-mt.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ struct SpinLock <: AbstractLock
3030
SpinLock() = new(Atomic{Int}(0))
3131
end
3232

33+
# Note: this cannot assert that the lock is held by the correct thread, because we do not
34+
# track which thread locked it. Users beware.
35+
Base.assert_havelock(l::SpinLock) = islocked(l) ? nothing : concurrency_violation()
36+
3337
function lock(l::SpinLock)
3438
while true
3539
if l.handle[] == 0

0 commit comments

Comments
 (0)