るりまサーチ

最速Rubyリファレンスマニュアル検索!
668件ヒット [1-100件を表示] (0.129秒)
トップページ > クエリ:e[x] > クラス:Thread[x]

別のキーワード

  1. open3 popen2e
  2. socket af_e164
  3. matrix det_e
  4. matrix rank_e
  5. open3 capture2e

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

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')
e
nd
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
e
nd
43.to_s
e
nd
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
e
nd
2.to_s
Thread
.current.set_trace_func nil
3.to_s
e
nd
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, #<...
<< 1 2 3 ... > >>