Project

General

Profile

Actions

Bug #5750

closed

Thread.current local-variables behavior

Added by schmurfy (Julien A) almost 13 years ago. Updated over 12 years ago.

Status:
Closed
Target version:
-
ruby -v:
1.9.3-p0
Backport:
[ruby-core:41606]

Description

Hi, I stumbled upon something which for me is a bug and wanted to check if it is working as intended or not:

Thread.current[:a] = 1
p Thread.current[:a] # => 1

Fiber.new do
 p Thread.current[:a] # => nil
end.resume

There is clearly a problem in either the documentation or the implementation for me there, we are in the same thread yet the returned values are different which is completely counter intuitive...
Why not add a fiber-variables store to allow the following and keep things separated between fibers and threads

Fiber.current[:a] = 1
p Fiber.current[:a] # => 1

Fiber.new do
 p Fiber.current[:a] # => nil
end.resume

Which is now the behavior I would expect.


Related issues 1 (0 open1 closed)

Is duplicate of Backport191 - Bug #1717: Thread local variables not visible from within a FiberRejected07/03/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0