44件ヒット
[1-44件を表示]
(0.270秒)
種類
- インスタンスメソッド (33)
- 文書 (11)
ライブラリ
- ビルトイン (33)
クラス
- Thread (33)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) - [] (11)
-
thread
_ variable _ get (11)
検索結果
先頭4件
-
Thread
# thread _ variable _ set(key , value) (18230.0) -
引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま す。
...引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま
す。
[注意]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)と
異なり、セットした変数は Fiber を切り替えても共通で使える事に注意してく......ださい。
//emlist[例][ruby]{
thr = Thread.new do
Thread.current.thread_variable_set(:cat, 'meow')
Thread.current.thread_variable_set("dog", 'woof')
end
thr.join # => #<Thread:0x401b3f10 dead>
thr.thread_variables # => [:dog, :cat]
//}
@see Thread#thread_variable_get, Threa... -
NEWS for Ruby 2
. 0 . 0 (24.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* Array#shuffle! と Array#sample の random パラメータには最大値のみを指定することが可能になりました
* Array#values_at に Range オブジェクトを与えた場合、配列の範囲外のインデックスについては nil を返します
* Enumerable......ariable_get スレッドローカルな変数を取得します
(these are different than Fiber local variables).
* 追加: Thread#thread_variable_set スレッドローカルな変数をセットします
* 追加: Thread#thread_variables スレッドローカルな変数の名前の......location
information. These are returned by Thread#backtrace_locations and
Kernel#caller_locations
* 非互換: Thread#join, Thread#value は対象のスレッドがメインスレッドか現在のスレッドである場合、
ThreadError を発生させます
* Time
*... -
Thread
# thread _ variable _ get(key) -> object | nil (18.0) -
引数 key で指定した名前のスレッドローカル変数を返します。
...)と
異なり、Fiber を切り替えても同じ変数を返す事に注意してください。
例:
Thread.new {
Thread.current.thread_variable_set("foo", "bar") # スレッドローカル
Thread.current["foo"] = "bar" # Fiber ローカル
Fiber.new {
Fi......# Fiber ローカル
]
}.resume
}.join.value # => ['bar', nil]
この例の "bar" は Thread#thread_variable_get により得られ
た値で、nil はThread#[] により得られた値です。
@see Thread#thread_variable_set, Thread#[]
@see https://magazine.rubyist.net/article... -
Thread
# [](name) -> object | nil (12.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...数を返す事に注意してください。
//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread.current[:name] = newvalue
yield
ensure
Thread.current[:name] = oldvalue
end
end
//}
この関数に与えるブロックがFiberを切り替える.......resume
p Thread.current[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2 is leaked to outside of meth method.)
//}
Fiber を切り替えても同じ変数を返したい場合は
Thread#thread_variable_get と Thread#thread_variable_set
を使用してください。
Thread#[]=......rrent[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2 is leaked to outside of meth method.)
//}
Fiber を切り替えても同じ変数を返したい場合は
Thread#thread_variable_get と Thread#thread_variable_set
を使用してください。
@see Thread#fetch, Thread#[]=...