Skip to content

Commit

Permalink
Split type checking and examining loops
Browse files Browse the repository at this point in the history
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
  • Loading branch information
mrkn and vtjnash committed Mar 4, 2024
1 parent 378854b commit 6c610d1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,22 @@ waitall(tasks; failfast=false) = _wait_multiple(tasks; all=true, failfast=failfa

function _wait_multiple(waiting_tasks; all=false, failfast=false)
tasks = Task[]
done_mask = Bool[]
exception = false
nremaining::Int = 0

for (i, t) in enumerate(waiting_tasks)
t isa Task || error("Expected an iterator of `Task` object")
push!(tasks, t)
end

exception = false
nremaining::Int = length(tasks)
done_mask = falses(nremaining)
for (i, t) in enumerate(tasks)
if istaskdone(t)
push!(done_mask, true)
done_mask[i] = true
exception |= istaskfailed(t)
nremaining -= 1
else
push!(done_mask, false)
nremaining += 1
done_mask[i] = false
end
end

Expand Down

0 comments on commit 6c610d1

Please sign in to comment.