Skip to content

Commit

Permalink
Remove dynamic dispatch from _wait/wait2 (#50202)
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Baraldi <baraldigabriel@gmail.com>
(cherry picked from commit e025877)
  • Loading branch information
vchuravy authored and KristofferC committed Jul 11, 2023
1 parent 01f9123 commit 7d01eaa
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,14 @@ end
# just wait for a task to be done, no error propagation
function _wait(t::Task)
if !istaskdone(t)
lock(t.donenotify)
donenotify = t.donenotify::ThreadSynchronizer
lock(donenotify)
try
while !istaskdone(t)
wait(t.donenotify)
wait(donenotify)
end
finally
unlock(t.donenotify)
unlock(donenotify)
end
end
nothing
Expand All @@ -330,13 +331,14 @@ function _wait2(t::Task, waiter::Task)
tid = Threads.threadid()
ccall(:jl_set_task_tid, Cint, (Any, Cint), waiter, tid-1)
end
lock(t.donenotify)
donenotify = t.donenotify::ThreadSynchronizer
lock(donenotify)
if !istaskdone(t)
push!(t.donenotify.waitq, waiter)
unlock(t.donenotify)
push!(donenotify.waitq, waiter)
unlock(donenotify)
return nothing
else
unlock(t.donenotify)
unlock(donenotify)
end
end
schedule(waiter)
Expand Down

0 comments on commit 7d01eaa

Please sign in to comment.