RosettaCodeData/Task/Synchronous-concurrency/Ruby/synchronous-concurrency-2.rb

13 lines
197 B
Ruby
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
count = 0
reader = Fiber.new do
IO.foreach("input.txt") { |line| Fiber.yield line }
puts "Printed #{count} lines."
nil
end
# printer
while line = reader.resume
print line
count += 1
end