From: "Muhammad A. Ali" Date: 2009-07-13T19:52:07+09:00 Subject: [ruby-core:24301] Re: [Bug #1717] Thread local variables not visible from within a Fiber --001485f7cbfaaf23ef046e941c4b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit That makes sense, but I had a need to share data across fibers running in the same thread, shouldn't there be a way to get hold to the parent thread's local storage? oldmoe On Sun, Jul 12, 2009 at 7:21 AM, Yusuke ENDOH wrote: > Hi, > > 2009/7/3 Muhammad Ali : > > Thread.current[:x] = 1 > > > > Fiber.new{Thread.current[:x]}.resume # => nil > > > > # returns nil when it should return 1 > > # even though Thread.current returns the same object > > > I've heard that this is intentional. Thread.current is both > thread-local and fiber-local storage. > > I can't really remember the rationale, but I think that most of > legacy libraries that uses thread-local storage will expect the > storage to be also fiber-local. > > -- > Yusuke ENDOH > > --001485f7cbfaaf23ef046e941c4b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
That makes sense, but I had a need to share data across fi= bers running in the same thread, shouldn't there be a way to get hold t= o the parent thread's local storage?

oldmoe

On Sun, Jul 12, 2009 at 7:21 AM, Yusuke ENDOH <mame@tsg.ne.jp>= ; wrote:
Hi,

2009/7/3 Muhammad Ali <redmine@= ruby-lang.org>:
> Thread.current[:x] =3D 1
>
> Fiber.new{Thread.current[:x]}.resume # =3D> nil
>
> # returns nil when it should return 1
> # even though Thread.current returns the same object


I've heard that this is intentional. =A0Thread.current is both thread-local and fiber-local storage.

I can't really remember the rationale, but I think that most of
legacy libraries that uses thread-local storage will expect the
storage to be also fiber-local.

--
Yusuke ENDOH <mame@tsg.ne.jp>

--001485f7cbfaaf23ef046e941c4b--