Thread-local variables in Fibers

I stumbled on an oddity with thread variables in fibers. I wonder if
this behaviour is intended and documented:

irb(main):001:0> Thread.current[:name] = "My name"
=> "My name"
irb(main):002:0> Fiber.new { Thread.current[:name] }.resume
=> nil

Even though, Thread.current is the same in a fiber as in the thread
invoking Fiber#resume.

irb(main):003:0> Fiber.new { Thread.current }.resume == Thread.current
=> true

Can anyone shed some light? I couldn't find any information in the
documentation.

ruby -v : ruby 1.9.1p243 (2009-07-16 revision 24175)

Even though, Thread.current is the same in a fiber as in the thread
invoking Fiber#resume.

irb(main):003:0> Fiber.new { Thread.current }.resume == Thread.current
=> true

Can anyone shed some light? I couldn't find any information in the
documentation.

There was some discussion on this in core. I can't remember if there
was consensus or not, but one person suggested it may be "intended" so
that you don't accidentally have fibers cross-using Thread.current for
their store, which wouldn't be fiber specific.
-r

ยทยทยท

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