Skip to content
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

Make any_gc_flag threadsafe #38200

Closed
Closed
Changes from 1 commit
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
25 changes: 19 additions & 6 deletions stdlib/Distributed/src/remotecall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,14 @@ function del_clients(pairs::Vector)
end
end

const any_gc_flag = Condition()
const any_gc_flag = Threads.Condition()
function start_gc_msgs_task()
@async while true
wait(any_gc_flag)
flush_gc_msgs()
@async begin
lock(any_gc_flag)
while true
wait(any_gc_flag)
flush_gc_msgs()
end
end
end

Expand All @@ -262,7 +265,12 @@ function send_del_client(rr)
w = worker_from_id(rr.where)
push!(w.del_msgs, (remoteref_id(rr), myid()))
w.gcflag = true
notify(any_gc_flag)
lock(any_gc_flag)
try
notify(any_gc_flag)
finally
unlock(any_gc_flag)
end
end
end

Expand Down Expand Up @@ -290,7 +298,12 @@ function send_add_client(rr::AbstractRemoteRef, i)
w = worker_from_id(rr.where)
push!(w.add_msgs, (remoteref_id(rr), i))
w.gcflag = true
notify(any_gc_flag)
lock(any_gc_flag)
try
notify(any_gc_flag)
finally
unlock(any_gc_flag)
end
end
end

Expand Down