44件ヒット
[1-44件を表示]
(0.301秒)
種類
- インスタンスメソッド (33)
- 文書 (11)
ライブラリ
- ビルトイン (33)
クラス
- Thread (33)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) - [] (11)
-
thread
_ variable _ get (11)
検索結果
先頭4件
-
Thread
# thread _ variable _ set(key , value) (18119.0) -
引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま す。
...える事に注意してく
ださい。
//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 Threa... -
NEWS for Ruby 2
. 0 . 0 (18.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ariable_get スレッドローカルな変数を取得します
(these are different than Fiber local variables).
* 追加: Thread#thread_variable_set スレッドローカルな変数をセットします
* 追加: Thread#thread_variables スレッドローカルな変数の名前の......ld backtrace location
information. These are returned by Thread#backtrace_locations and
Kernel#caller_locations
* 非互換: Thread#join, Thread#value は対象のスレッドがメインスレッドか現在のスレッドである場合、
ThreadError を発生させます......cond argument is true.
* Object#respond_to_missing?, Object#initialize_clone, Object#initialize_dup
* private になりました
* Thread#join, Thread#value
* 上を参照
* Mutex#lock, Mutex#unlock, Mutex#try_lock, Mutex#synchronize, Mutex#sleep
* 上を参照
=== 標準添付... -
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/arti... -
Thread
# [](name) -> object | nil (12.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...{ Thread.current["name"] = "A" },
Thread.new { Thread.current[:name] = "B" },
Thread.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts "#{th.inspect}: #{th[:name]}"
end
# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a.......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#[]=...