RosettaCodeData/Task/Synchronous-concurrency/Ruby/synchronous-concurrency-2.rb
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

12 lines
197 B
Ruby

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