401件ヒット
[1-100件を表示]
(0.020秒)
ライブラリ
- ビルトイン (240)
-
irb
/ context (12) - monitor (18)
- thwait (54)
クラス
-
IRB
:: Context (12) - Monitor (18)
- Thread (221)
- ThreadsWait (54)
モジュール
- Kernel (7)
キーワード
-
$ SAFE (7) -
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 3
. 0 . 0 (5) - ThreadGroup (12)
- [] (12)
- alive? (12)
-
all
_ waits (18) - drb (12)
- empty? (6)
- exit (12)
- fetch (8)
- finished? (6)
- group (12)
- inspect (12)
- irb (12)
- join (6)
-
join
_ nowait (6) - key? (12)
- keys (12)
-
mon
_ exit (6) - new (6)
- priority (12)
- priority= (12)
-
rb
_ thread _ current (12) -
report
_ on _ exception (9) -
report
_ on _ exception= (9) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
safe
_ level (7) -
set
_ trace _ func (12) - status (12)
- stop? (12)
-
thread
_ variable? (12) -
thread
_ variable _ get (12) -
thread
_ variable _ set (12) - threads (6)
-
to
_ s (8)
検索結果
先頭5件
-
Thread
. current -> Thread (27220.0) -
現在実行中のスレッド(カレントスレッド)を返します。
...現在実行中のスレッド(カレントスレッド)を返します。
p Thread.current #=> #<Thread:0x4022e6fc run>... -
IRB
:: Context # thread -> Thread (18214.0) -
現在のスレッドを返します。
...現在のスレッドを返します。
@see Thread.current... -
Thread
# thread _ variable _ get(key) -> object | nil (15209.0) -
引数 key で指定した名前のスレッドローカル変数を返します。
...]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)と
異なり、Fiber を切り替えても同じ変数を返す事に注意してください。
例:
Thread.new {
Thread.current.thread_variable_set("foo", "bar") # スレッドローカル
Thread.current["foo"......
Thread.current.thread_variable_get("foo"), # スレッドローカル
Thread.current["foo"], # Fiber ローカル
]
}.resume
}.join.value # => ['bar', nil]
この例の "bar" は Thread#thread_variable_get により得られ
た値で、nil はThread......#[] により得られた値です。
@see Thread#thread_variable_set, Thread#[]
@see https://magazine.rubyist.net/articles/0041/0041-200Special-note.html... -
Thread
# thread _ variable _ set(key , value) (15179.0) -
引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま す。
...]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)と
異なり、セットした変数は Fiber を切り替えても共通で使える事に注意してく
ださい。
//emlist[例][ruby]{
thr = Thread.new do
Thread.current.thread_variable_set(:cat, 'meow')
Thread.c......urrent.thread_variable_set("dog", 'woof')
end
thr.join # => #<Thread:0x401b3f10 dead>
thr.thread_variables # => [:dog, :cat]
//}
@see Thread#thread_variable_get, Thread#[]... -
Thread
# thread _ variable?(key) -> bool (15155.0) -
引数 key で指定した名前のスレッドローカル変数が存在する場合に true、そ うでない場合に false を返します。
...= Thread.current
me.thread_variable_set(:oliver, "a")
me.thread_variable?(:oliver) # => true
me.thread_variable?(:stanley) # => false
[注意]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)が
対象ではない事に注意してください。
@see Thread......#thread_variable_get, Thread#[]... -
VALUE rb
_ thread _ current(void) (12200.0) -
現在実行中のスレッドを返します。
現在実行中のスレッドを返します。 -
Thread
# [](name) -> object | nil (9174.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...emlist[例][ruby]{
[
Thread.new { 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 d......002a54130 dead>: C
//}
Thread#[] と Thread#[]= を用いたスレッド固有の変数は
Fiber を切り替えると異なる変数を返す事に注意してください。
//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread.current[:name] = newvalue......read.current[:name] = oldvalue
end
end
//}
この関数に与えるブロックがFiberを切り替える場合は動的スコープとしては
正しく動作しません。
//emlist[][ruby]{
f = Fiber.new {
meth(1) {
Fiber.yield
}
}
meth(2) {
f.resume
}
f.resume
p Thread.current[:na... -
ThreadsWait
# threads -> Array (9136.0) -
同期されるスレッドの一覧を配列で返します。
...ドの一覧を配列で返します。
使用例
require 'thwait'
threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new(*threads)
p thall.threads
#=> [#<Thread:0x21750 sleep>, #<Thread:0x216c4 sleep>, #<Thread:0x21638 sleep>]... -
Thread
# group -> ThreadGroup (9112.0) -
スレッドが属している ThreadGroup オブジェクトを返します。
...スレッドが属している ThreadGroup オブジェクトを返します。
p Thread.current.group == ThreadGroup::Default
# => true...