Skip to content

Commit f7a6648

Browse files
committed
rework the thread unsafe test to make it more meaningful
1 parent fddd155 commit f7a6648

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

stdlib/LinearAlgebra/test/blas.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,16 +651,16 @@ end
651651

652652
@testset "thread unsafe" begin
653653
prev_num_threads = BLAS.get_num_threads()
654-
# thread unsafe
655-
@async BLAS.with_num_threads(1) do
654+
context_num_threads = 1
655+
# task A
656+
t = @async BLAS.with_num_threads(context_num_threads) do
656657
sleep(0.5)
657658
end
658659
sleep(0.1)
659-
660-
context_num_threads = BLAS.get_num_threads()
661-
@test context_num_threads == 1
662-
663-
sleep(0.5) # wait for the task to finish
660+
# check that main thread is affected by task A
661+
@test BLAS.get_num_threads() == context_num_threads
662+
# when the task finishes, the num threads get restored
663+
wait(t)
664664
@test prev_num_threads == BLAS.get_num_threads()
665665
end
666666
end

0 commit comments

Comments
 (0)