[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Where is Fiber::Core in Ruby 1.9?

Chiyuan Zhang

2/19/2008 9:25:00 AM

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!
1 Answer

Chiyuan Zhang

2/19/2008 1:01:00 PM

0

Oh! Thanks! So, in the Ruby 1.9 Release. Fiber and Fiber::Core are merged.

2008/2/19, ts <decoux@moulon.inra.fr>:
> >>>>> "p" == pluskid <pluskid@gmail.com> writes:
>
> p> f = Fiber::Core.new { |x|
>
> gsub(/::Core/, '')
>
> vgs% cat b.rb
> require 'fiber'
> f = g = nil
>
> f = Fiber.new { |x|
> puts "F1: #{x}"
> x = g.transfer(x+1)
> puts "F2: #{x}"
> x = g.transfer(x+1)
> puts "F3: #{x}"
> }
>
> g = Fiber.new { |x|
> puts "G1: #{x}"
> x = f.transfer(x+1)
> puts "G2: #{x}"
> x = f.transfer(x+1)
> }
>
> f.transfer(100)
> vgs%
>
> vgs% ./ruby -v b.rb
> ruby 1.9.0 (2008-02-18 revision 15525) [i686-linux]
> F1: 100
> G1: 101
> F2: 102
> G2: 103
> F3: 104
> vgs%
>
>
> Guy Decoux
>
>