Where is Fiber::Core in Ruby 1.9?

Discussion in 'Ruby' started by pluskid, Feb 19, 2008.

  1. pluskid

    pluskid Guest

    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!
    pluskid, Feb 19, 2008
    #1
    1. Advertising

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

    2008/2/19, ts <>:
    > >>>>> "p" == pluskid <> 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
    >
    >
    Chiyuan Zhang, Feb 19, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Akihiro KAYAMA

    fiber(cooperative multi-threading)

    Akihiro KAYAMA, Dec 22, 2007, in forum: Python
    Replies:
    17
    Views:
    616
    Bjoern Schliessmann
    Dec 28, 2007
  2. Replies:
    0
    Views:
    262
  3. Suraj Kurapati

    Ruby 1.9 - equivalent of Fiber.current ?

    Suraj Kurapati, Mar 2, 2008, in forum: Ruby
    Replies:
    2
    Views:
    115
    Suraj Kurapati
    Mar 2, 2008
  4. Roger Pack
    Replies:
    3
    Views:
    148
    Roger Pack
    Jun 16, 2008
  5. Iñaki Baz Castillo

    How to know whether current Fiber is the root Fiber?

    Iñaki Baz Castillo, Apr 8, 2011, in forum: Ruby
    Replies:
    4
    Views:
    308
    Robert Klemme
    Apr 11, 2011
Loading...

Share This Page