Skip to content

Create workers only once in the thread-safety tests #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions test/threads.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Test
using DistributedNext, Base.Threads
using DistributedNext
using Base.Iterators: product

exeflags = ("--startup-file=no",
Expand All @@ -12,7 +12,7 @@ function call_on(f, wid, tid)
t = Task(f)
ccall(:jl_set_task_tid, Cvoid, (Any, Cint), t, tid - 1)
schedule(t)
@assert threadid(t) == tid
@assert Threads.threadid(t) == tid
t
end
end
Expand All @@ -27,12 +27,12 @@ isfailed(rr) = fetch_from_owner(istaskfailed, rr)

@testset "RemoteChannel allows put!/take! from thread other than 1" begin
ws = ts = product(1:2, 1:2)

# We want (the default) laziness, so that we wait for `Worker.c_state`!
procs_added = addprocs(2; exeflags, lazy=true)

@testset "from worker $w1 to $w2 via 1" for (w1, w2) in ws
@testset "from thread $w1.$t1 to $w2.$t2" for (t1, t2) in ts
# We want (the default) laziness, so that we wait for `Worker.c_state`!
procs_added = addprocs(2; exeflags, lazy=true)
@everywhere procs_added using Base.Threads

p1 = procs_added[w1]
p2 = procs_added[w2]
chan_id = first(procs_added)
Expand All @@ -57,8 +57,8 @@ isfailed(rr) = fetch_from_owner(istaskfailed, rr)

@test !isfailed(send)
@test !isfailed(recv)

rmprocs(procs_added)
end
end

rmprocs(procs_added)
end
Loading