--RnlQjJ0d97Da+TV1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Oct 02, 2012 at 10:34:47AM +0900, SASADA Koichi wrote:
> (2012/10/02 9:42), Aaron Patterson wrote:
> > On Tue, Oct 02, 2012 at 08:32:51AM +0900, SASADA Koichi wrote:
> >> (2012/10/02 8:22), SASADA Koichi wrote:
> >>>
> >>> One idea is:
> >>>
> >>>   - Define: Thread#[] -> Thred#current_fiber#[]
> >>>   - Add: Thread#truly_thread_local_get(key)
> >>>     and  Thread#truly_thread_local_set(key, val)
> >>>
> >>> (of course, truly_... is temporal name)
> >=20
> > I prefer this solution.  I want a way to set true thread locals.
> >=20
> >> Another idea:
> >>
> >> Add an option to derive Fiber local storage at a Fiber creation.
> >>
> >>   For example:
> >>
> >>     Thread[:foo] =3D :bar
> >>     Fiber.new(derive_fiber_local_storage: true) do
> >>       Thread[:foo] #=3D> :bar
> >>     end
> >>
> >> And use Fiber in enumerator with this option true.
> >=20
> > I think the "true thread local" solution is better than this because I
> > can use it with existing fiber based code.  If a third party library
> > uses Fibers, and I want thread locals, it would not be possible with
> > this solution.
>=20
> I'm afraid that people overuse it rather than Fiber local storage.  The
> reason why Thread local is Fiber local is that most of thread locals
> should be fiber local.
>=20
> I think we need to discuss carefully.

The problem I'm facing is with database connections.  Database
connections can't be shared among threads (since no parallel access is
allowed).  I don't want to pass the connection to every function call,
so a thread local makes sense for connection storage.

AFAIK, Fibers cannot run in parallel, so it's OK for two Fibers to share
a database connection.

Does this make sense?  Maybe my assumption is wrong about Fibers.

--=20
Aaron Patterson
http://tenderlovemaking.com/

--RnlQjJ0d97Da+TV1
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (Darwin)

iQEcBAEBAgAGBQJQan0OAAoJEJUxcLy0/6/Gds4IAJO1tjyy9zCr7wPG7tXPzCSx
5IJaji5o4NDdCFdeANK5lr5zE9j96Xu9nnqsmoNpswZt5shbS8p1I+xuusR+cujg
QAh9yioX3TwqH8fMLuQ1wcaf6/PdTObf8JhU5MH6P3dMx6gKRuyi5EaPFjneY1wQ
wPDhLWUViuEAo+1TfjYhV6DaMpnOg3Ch6+w4tqJcFP3XEJgXhPn4sjLtwq2IAfeN
5nBOgLoC6iSiSx/X952W+WockD9EIl9MKknT52bDbV1eUWMcqX/WOtFwfoqdBfi4
KaycLIzv7seUWt14VYF7mWgUkttQ53e+L40kjEhjQVfqA7UpveqOa3tFSfNMOBY=
=okYz
-----END PGP SIGNATURE-----

--RnlQjJ0d97Da+TV1--