種類
- インスタンスメソッド (441)
- 特異メソッド (222)
- 定数 (5)
ライブラリ
- ビルトイン (668)
キーワード
- DEBUG (12)
- DEBUG= (12)
-
MUTEX
_ FOR _ THREAD _ EXCLUSIVE (5) - [] (12)
- []= (12)
-
abort
_ on _ exception (24) -
abort
_ on _ exception= (24) -
add
_ trace _ func (12) - alive? (12)
- backtrace (12)
-
backtrace
_ locations (24) - current (12)
- exclusive (12)
- exit (24)
- fetch (8)
- fork (12)
- group (12)
-
handle
_ interrupt (12) -
ignore
_ deadlock (4) -
ignore
_ deadlock= (4) - inspect (12)
- join (24)
- key? (12)
- keys (12)
- kill (24)
- list (12)
- main (12)
- name (10)
- name= (10)
- new (12)
- pass (12)
-
pending
_ interrupt? (24) - priority (12)
- priority= (12)
- raise (12)
-
report
_ on _ exception (18) -
report
_ on _ exception= (18) - run (12)
-
safe
_ level (7) -
set
_ trace _ func (12) - start (12)
- status (12)
- stop (12)
- stop? (12)
- terminate (12)
-
thread
_ variable? (12) -
thread
_ variable _ get (12) -
thread
_ variable _ set (12) -
to
_ s (8) - value (12)
- wakeup (12)
検索結果
先頭5件
-
Thread
:: MUTEX _ FOR _ THREAD _ EXCLUSIVE -> Mutex (12301.0) -
Thread.exclusive用のMutexオブジェクトです。
...
Thread.exclusive用のMutexオブジェクトです。......
Thread.exclusive用のMutexオブジェクトです。
(private constant です。)... -
Thread
. report _ on _ exception -> bool (9213.0) -
真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...を $stderr に報告します。
デフォルトは false です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block......in <main>'
1: from -e:1:in `times'
これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:
* 例外が......で rescue して、
その例外でスレッドが終了しないようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレ......容を $stderr に報告します。
デフォルトは true です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `blo......ck in <main>'
1: from -e:1:in `times'
これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:
* 例外が... -
Thread
. report _ on _ exception=(newstate) (9213.0) -
真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...を $stderr に報告します。
デフォルトは false です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block......in <main>'
1: from -e:1:in `times'
これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:
* 例外が......で rescue して、
その例外でスレッドが終了しないようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレ......容を $stderr に報告します。
デフォルトは true です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `blo......ck in <main>'
1: from -e:1:in `times'
これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:
* 例外が... -
Thread
# report _ on _ exception -> bool (9201.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...derr に報告します。
デフォルトはスレッド作成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread......; raise }
a.report_on_exception = true
a.report_on_exception # => true
a.run
# => #<Thread:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00......007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}
@see Thread.report_on_exception... -
Thread
# report _ on _ exception=(newstate) (9201.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...derr に報告します。
デフォルトはスレッド作成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread......; raise }
a.report_on_exception = true
a.report_on_exception # => true
a.run
# => #<Thread:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00......007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}
@see Thread.report_on_exception... -
Thread
# ignore _ deadlock -> bool (9101.0) -
デッドロック検知を無視する機能のon/offを返します。
...デッドロック検知を無視する機能のon/offを返します。
デフォルト値はfalseで、デッドロックが検知されます。
@see Thread#ignore_deadlock=... -
Thread
# ignore _ deadlock=(bool) (9101.0) -
デッドロック検知を無視する機能をon/offします。デフォルト値はfalseです。
...seです。
trueを渡すとデッドロックを検知しなくなります。
//emlist[][ruby]{
Thread.ignore_deadlock = true
queue = Thread::Queue.new
trap(:SIGUSR1){queue.push "Received signal"}
# ignore_deadlockがfalseだとエラーが発生する
puts queue.pop
//}
@see Thread#ignore_de... -
Thread
# thread _ variable?(key) -> bool (9101.0) -
引数 key で指定した名前のスレッドローカル変数が存在する場合に true、そ うでない場合に false を返します。
...key で指定した名前のスレッドローカル変数が存在する場合に true、そ
うでない場合に false を返します。
@param key 変数名を String か Symbol で指定します。
me = 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#[]... -
Thread
# thread _ variable _ get(key) -> object | nil (9101.0) -
引数 key で指定した名前のスレッドローカル変数を返します。
...key で指定した名前のスレッドローカル変数を返します。
[注意]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)と
異なり、Fiber を切り替えても同じ変数を返す事に注意してください。
例:
Thread.new {
Thread.current.......thread_variable_set("foo", "bar") # スレッドローカル
Thread.current["foo"] = "bar" # Fiber ローカル
Fiber.new {
Fiber.yield [
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/00... -
Thread
# thread _ variable _ set(key , value) (9101.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, Thread#[]... -
Thread
# add _ trace _ func(pr) -> Proc (6161.0) -
スレッドにトレース用ハンドラを追加します。
...//emlist[例][ruby]{
th = Thread.new do
class Trace
end
43.to_s
end
th.add_trace_func lambda {|*arg| p arg }
th.join
# => ["line", "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "example.rb", 4, :inherited, #<Binding:0x00007f98e1087448>, Class]
# => ["c-return", "ex......e.rb", 4, :inherited, #<Binding:0x00007f98e1085d00>, Class]
# => ["class", "example.rb", 4, nil, #<Binding:0x00007f98e108f210>, nil]
# => ["end", "example.rb", 5, nil, #<Binding:0x00007f98e108e5e0>, nil]
# => ["line", "example.rb", 6, nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.......rb", 6, :to_s, #<Binding:0x00007f98e1097aa0>, Integer]
# => ["c-return", "example.rb", 6, :to_s, #<Binding:0x00007f98e1095cc8>, Integer]
//}
@see Thread#set_trace_func Kernel.#set_trace_func... -
Thread
# set _ trace _ func(pr) -> Proc | nil (6113.0) -
スレッドにトレース用ハンドラを設定します。
...す。
//emlist[例][ruby]{
th = Thread.new do
class Trace
end
2.to_s
Thread.current.set_trace_func nil
3.to_s
end
th.set_trace_func lambda {|*arg| p arg }
th.join
# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Bindi......ng:0x00007fc8de886770>, Class]
# => ["c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Bi......07fc8de88c440>, nil]
# => ["c-call", "example.rb", 4, :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current, #<...