public
Last active

  • Download Gist
fiber.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class Fiber
include Enumerable
def each
begin
loop { yield self.resume }
rescue FiberError
end
end
end
 
puts Fiber.new {
Fiber.yield 3
Fiber.yield 2
Fiber.yield 1
Fiber.yield 0
}.to_enum.to_a

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.