[#47605] Rubyでも「private」イコール「非公開」? — Makoto Kuwata <kwa@...>

桑田といいます。

12 messages 2010/11/04
[#47606] Re: Rubyでも「private」イコール「非公開」? — Yusuke ENDOH <mame@...> 2010/11/04

private constant 提案者の遠藤です。

[ruby-list:47624] ファイバとスレッド固有データ

From: Kenta Murata <muraken@...>
Date: 2010-11-09 03:23:29 UTC
List: ruby-list #47624
むらたです。

ファイバの内側と外側は同一スレッドに入っていますが、
以下のコードによってスレッド固有データが分離されている事が
確認されました。


 Thread.current[:abc] = 1

 fb = Fiber.new do
  th = Thread.current
  p [th, th[:abc]]
  th[:abc] = 2
 end

 th = Thread.current
 p [th, th[:abc]]    #=> [#<Thread:0x00000100887560 run>, 1]
 fb.resume           #=> [#<Thread:0x00000100887560 run>, nil]
 p [th, th[:abc]]    #=> [#<Thread:0x00000100887560 run>, 1]


この動作は仕様で決められたものでしょうか?
それとも、たまたまこのように実装されてるだけなのでしょうか?


--
Kenta Murata
OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54  98C1 CEFE 8AFB 6081 B062

本を書きました!!
『Ruby 逆引きレシピ』 http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: mrkn@mrkn.jp
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/


In This Thread

Prev Next