種類
- インスタンスメソッド (402)
- 特異メソッド (203)
- 定数 (5)
キーワード
- DEBUG (11)
- DEBUG= (11)
-
MUTEX
_ FOR _ THREAD _ EXCLUSIVE (5) - [] (11)
- []= (11)
-
abort
_ on _ exception (22) -
abort
_ on _ exception= (22) -
add
_ trace _ func (11) - alive? (11)
- backtrace (11)
-
backtrace
_ locations (22) - current (11)
- exclusive (11)
- exit (22)
- fetch (7)
- fork (11)
- group (11)
-
handle
_ interrupt (11) -
ignore
_ deadlock (3) -
ignore
_ deadlock= (3) - inspect (11)
- join (22)
- key? (11)
- keys (11)
- kill (22)
- list (11)
- main (11)
- name (9)
- name= (9)
- new (11)
- pass (11)
-
pending
_ interrupt? (22) - priority (11)
- priority= (11)
- raise (11)
-
report
_ on _ exception (16) -
report
_ on _ exception= (16) - run (11)
-
safe
_ level (7) -
set
_ trace _ func (11) - start (11)
- status (11)
- stop (11)
- stop? (11)
- terminate (11)
-
thread
_ variable? (11) -
thread
_ variable _ get (11) -
thread
_ variable _ set (11) -
to
_ s (7) - value (11)
- wakeup (11)
検索結果
先頭5件
-
Thread
# name -> String (3.0) -
self の名前を返します。
...self の名前を返します。
@see Thread#name=... -
Thread
# name=(name) -> String (3.0) -
self の名前を name に設定します。
...ームによっては pthread やカーネルにも設定を行う場合があります。
@raise ArgumentError 引数に ASCII 互換ではないエンコーディングのものを
指定した場合に発生します。
//emlist[例][ruby]{
a = Thread.new{}
a.name = 'named'......a.name # => "named"
a.inspect # => "#<Thread:0x00007f85ac8721f0@named@(irb):1 dead>"
//}
@see Thread#name... -
Thread
# pending _ interrupt?(error = nil) -> bool (3.0) -
self の非同期例外のキューが空かどうかを返します。
...self の非同期例外のキューが空かどうかを返します。
@param error 対象の例外クラスを指定します。
@see Thread.pending_interrupt?... -
Thread
# priority -> Integer (3.0) -
スレッドの優先度を返します。この値が大きいほど優先度が高くなります。 メインスレッドのデフォルト値は 0 です。新しく生成されたスレッドは親スレッドの priority を引き継ぎます。
...定します。プラットフォームに依存します。
//emlist[例][ruby]{
Thread.current.priority # => 0
count1 = count2 = 0
a = Thread.new do
loop { count1 += 1 }
end
a.priority = -1
b = Thread.new do
loop { count2 += 1 }
end
b.priority = -2
count1 = count2 = 0 # re... -
Thread
# priority=(val) (3.0) -
スレッドの優先度を返します。この値が大きいほど優先度が高くなります。 メインスレッドのデフォルト値は 0 です。新しく生成されたスレッドは親スレッドの priority を引き継ぎます。
...定します。プラットフォームに依存します。
//emlist[例][ruby]{
Thread.current.priority # => 0
count1 = count2 = 0
a = Thread.new do
loop { count1 += 1 }
end
a.priority = -1
b = Thread.new do
loop { count2 += 1 }
end
b.priority = -2
count1 = count2 = 0 # re... -
Thread
# raise(error _ type , message , traceback) -> () (3.0) -
自身が表すスレッドで強制的に例外を発生させます。
...してください。
@param message Kernel.#raise を参照してください。
@param traceback Kernel.#raise を参照してください。
Thread.new {
sleep 1
Thread.main.raise "foobar"
}
begin
sleep
rescue
p $!, $@
end
=> #<RuntimeError: foobar>
["-:3"]... -
Thread
# report _ on _ exception -> bool (3.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...ルトはスレッド作成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
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:0x00007fc3f48c7908@(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) (3.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...ルトはスレッド作成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
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:0x00007fc3f48c7908@(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
# run -> self (3.0) -
停止状態(stop)のスレッドを再開させます。 Thread#wakeup と異なりすぐにスレッドの切り替え を行います。
...レッドを再開させます。
Thread#wakeup と異なりすぐにスレッドの切り替え
を行います。
@raise ThreadError 死んでいるスレッドに対して実行すると発生します。
//emlist[例][ruby]{
a = Thread.new { puts "a"; Thread.stop; puts "c" }
sleep 0.1 while a.......status!='sleep'
puts "Got here"
a.run
a.join
# => a
# => Got here
# => c
//}
@see Thread#wakeup, Thread.stop... -
Thread
# safe _ level -> Integer (3.0) -
self のセーフレベルを返します。カレントスレッドの safe_level は、$SAFE と同じです。
...ローバルになったため、このメソッドは obsolete になりました。
セーフレベルについてはspec/safelevelを参照してください。
//emlist[例][ruby]{
thr = Thread.new { $SAFE = 1; sleep }
Thread.current.safe_level # => 0
thr.safe_level # => 1
//}......obsolete になりました。
単純に $SAFE をチェックしてください。
セーフレベルについてはspec/safelevelを参照してください。
//emlist[例][ruby]{
thr = Thread.new { $SAFE = 1; sleep }
Thread.current.safe_level # => 0
thr.safe_level # => 1
//}... -
Thread
# set _ trace _ func(pr) -> Proc | nil (3.0) -
スレッドにトレース用ハンドラを設定します。
...nil を渡すとトレースを解除します。
設定したハンドラを返します。
//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,......fc8de967798>, Thread]
# => ["c-return", "example.rb", 5, :current, #<Binding:0x00007fc8de9673b0>, Thread]
# => ["c-call", "example.rb", 5, :set_trace_func, #<Binding:0x00007fc8de966fc8>, Thread]
//}
@param pr トレースハンドラ(Proc オブジェクト) もしくは nil
@see Thread#add_trace_f...