L
Lars Christensen
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)
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)