Skip to content

Commit

Permalink
Wrap the new test in a @testset
Browse files Browse the repository at this point in the history
  • Loading branch information
kuszmaul committed Oct 1, 2024
1 parent 1af733c commit 29916f8
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions test/threads_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,25 @@ if threadpoolsize() > 1
end
end

# basic padded spin lock check
if threadpoolsize() > 1
let lk = PaddedSpinLock()
c1 = Base.Event()
c2 = Base.Event()
@test trylock(lk)
@test !trylock(lk)
t1 = Threads.@spawn (notify(c1); lock(lk); unlock(lk); trylock(lk))
t2 = Threads.@spawn (notify(c2); trylock(lk))
Libc.systemsleep(0.1) # block our thread from scheduling for a bit
wait(c1)
wait(c2)
@test !fetch(t2)
@test istaskdone(t2)
@test !istaskdone(t1)
unlock(lk)
@test fetch(t1)
@test istaskdone(t1)
@testset "basic padded spin lock check"
if threadpoolsize() > 1
let lk = PaddedSpinLock()
c1 = Base.Event()
c2 = Base.Event()
@test trylock(lk)
@test !trylock(lk)
t1 = Threads.@spawn (notify(c1); lock(lk); unlock(lk); trylock(lk))
t2 = Threads.@spawn (notify(c2); trylock(lk))
Libc.systemsleep(0.1) # block our thread from scheduling for a bit
wait(c1)
wait(c2)
@test !fetch(t2)
@test istaskdone(t2)
@test !istaskdone(t1)
unlock(lk)
@test fetch(t1)
@test istaskdone(t1)
end
end
end

Expand Down

0 comments on commit 29916f8

Please sign in to comment.