Skip to content

Commit

Permalink
Fix: expect N responses from forked processes
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Feb 13, 2024
1 parent 2f1af88 commit 434edae
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/compiler/crystal/compiler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -567,24 +567,25 @@ module Crystal

workers.each do |pid, input, output|
spawn do
overqueued = 0

overqueue.times do
if (index = indexes.add(1)) < units.size
input.puts index
overqueued += 1
end
end

while (index = indexes.add(1)) < units.size
input.puts index

if response = output.gets(chomp: true)
channel.send response
end
response = output.gets(chomp: true).not_nil!
channel.send response
end

overqueue.times do
if response = output.gets(chomp: true)
channel.send response
end
overqueued.times do
response = output.gets(chomp: true).not_nil!
channel.send response
end

input << '\n'
Expand Down

0 comments on commit 434edae

Please sign in to comment.