From: David Flanagan Date: 2007-08-23T03:49:51+09:00 Subject: coroutines with Fiber::Core The following code works on Linux with today's snapshot of 1.9: f = g = nil f = Fiber::Core.new { |x| puts "F1: #{x}" x = g.transfer(x+1) puts "F2: #{x}" x = g.transfer(x+1) puts "F3: #{x}" } g = Fiber::Core.new { |x| puts "G1: #{x}" x = f.transfer(x+1) puts "G2: #{x}" x = f.transfer(x+1) } f.transfer(100) It prints: F1: 100 G1: 101 F2: 102 G2: 103 F3: 104 You can also use the higher-level Fiber (instead of Fiber::Core) API, but I don't understand it as well: g = Fiber.new { |x| puts "G1: #{x}" x = Fiber.yield(x+1) # Can't use resume here: double resume error puts "G2: #{x}" x = Fiber.yield(x+1) } f = Fiber.new { |x| puts "F1: #{x}" x = g.resume(x+1) puts "F2: #{x}" x = g.resume(x+1) puts "F3: #{x}" } f.resume(100) These seem more interesting that continuations, so I understand why Matz would say that Fibers are more likely to stay in 1.9 than continuations are. David