P
pluskid
Hi! I found some articles introduce the Fiber in Ruby 1.9. And also
Fiber::Core as the coroutine support in Ruby. Here's an example:
require 'fiber'
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)
But when I run this example, I got an error:
NameError: uninitialized constant Fiber::Core
I'm using Ruby1.9 package of Debian lenny: Version: 1.9.0.0-2
Is the api changed? Or has Fiber::Core been removed? Thanks!
Fiber::Core as the coroutine support in Ruby. Here's an example:
require 'fiber'
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)
But when I run this example, I got an error:
NameError: uninitialized constant Fiber::Core
I'm using Ruby1.9 package of Debian lenny: Version: 1.9.0.0-2
Is the api changed? Or has Fiber::Core been removed? Thanks!