Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2552

Re: How to know whether current Fiber is the root Fiber?

From 7stud -- <bbxx789_05ss@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: How to know whether current Fiber is the root Fiber?
Date 2011-04-08 13:56 -0500
Organization Service de news de lacave.net
Message-ID <306caacb747dfc99c7d49c815ad456cb@ruby-forum.com> (permalink)
References <BANLkTinQAU_BbiTucU5DKxNXiFXyTcE9TQ@mail.gmail.com> <924f39251213390fb702027274090882@ruby-forum.com>

Show all headers | View raw


7stud -- wrote in post #991816:
>
> For example:
>
> require 'fiber'
>
> root_fiber = Fiber.current
>
> f = Fiber.new do
>   if Fiber.current.eql?(f)
>     puts 'not root fiber'
>   else
>     puts 'root fiber'
>   end
>
>   Fiber.yield "hello world"
> end
>
> f.resume
>
> --output:--
> not root fiber
> root fiber

Instead, make that:

require 'fiber'

root_fiber = Fiber.current

f = Fiber.new do
  if Fiber.current.eql?(root_fiber)
    puts 'root fiber'
  else
    puts 'not root fiber'
  end

  Fiber.yield "hello world"
end

f.resume

if Fiber.current.eql?(root_fiber)
  puts 'root fiber'
else
  puts 'not root fiber'
end

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to know whether current Fiber is the root Fiber? Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-08 07:30 -0500
  Re: How to know whether current Fiber is the root Fiber? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-08 13:37 -0500
    Re: How to know whether current Fiber is the root Fiber? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-08 13:56 -0500
      Re: How to know whether current Fiber is the root Fiber? Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-11 02:30 -0500
        Re: How to know whether current Fiber is the root Fiber? Robert Klemme <shortcutter@googlemail.com> - 2011-04-11 02:52 -0500

csiph-web