ライブラリ
クラス
-
DRb
:: DRbServer (12) - Exception (12)
- Fiber (24)
-
IRB
:: Context (12) - Monitor (42)
- Mutex (8)
-
Net
:: IMAP (48) -
Net
:: IMAP :: ThreadMember (24) -
Rake
:: Application (12) - Thread (441)
-
Thread
:: Backtrace :: Location (84) -
Thread
:: ConditionVariable (36) -
Thread
:: Mutex (70) -
Thread
:: Queue (152) -
Thread
:: SizedQueue (130) - ThreadGroup (48)
- ThreadsWait (42)
- Tracer (12)
-
WEBrick
:: GenericServer (12)
モジュール
- Kernel (16)
- MonitorMixin (12)
-
Sync
_ m (24)
キーワード
- << (24)
- [] (12)
- []= (12)
-
abort
_ on _ exception (12) -
abort
_ on _ exception= (12) -
absolute
_ path (12) - add (12)
-
add
_ trace _ func (12) - alive? (12)
-
all
_ waits (6) - backtrace (12)
-
backtrace
_ locations (36) -
base
_ label (12) - broadcast (12)
- children (12)
- clear (12)
-
client
_ thread (12) -
client
_ thread= (12) - close (20)
- closed? (10)
- deq (24)
- empty? (26)
- enclose (12)
- enclosed? (12)
- enq (24)
- enter (12)
- exit (24)
- fetch (8)
- finished? (6)
-
get
_ thread _ no (12) - group (12)
-
ignore
_ deadlock (4) -
ignore
_ deadlock= (4) - inspect (24)
- join (30)
-
join
_ nowait (6) - key? (12)
- keys (12)
- kill (12)
- label (12)
- length (20)
- lineno (12)
- list (12)
- lock (12)
- locked? (10)
- max (12)
- max= (12)
-
mon
_ enter (18) -
mon
_ exit (6) - name (10)
- name= (10)
-
next
_ wait (6) -
num
_ waiting (12) - owned? (12)
- path (12)
-
pending
_ interrupt? (12) - pop (24)
- priority (12)
- priority= (12)
- push (24)
- raise (12)
-
report
_ on _ exception (9) -
report
_ on _ exception= (9) - resume (12)
- run (12)
-
safe
_ level (7) - seqno (12)
-
set
_ trace _ func (12) - shift (24)
- signal (12)
- size (20)
- sleep (12)
- status (12)
- stop? (12)
-
sync
_ ex _ locker (6) -
sync
_ ex _ locker= (6) -
sync
_ upgrade _ waiting (6) -
sync
_ waiting (6) - synchronize (10)
- terminate (12)
-
thread
_ variable? (12) -
thread
_ variable _ get (12) -
thread
_ variable _ set (12) - threads (6)
- timeout (16)
-
to
_ s (20) - tokens (12)
- transfer (12)
-
try
_ lock (10) -
uid
_ thread (12) - unlock (12)
- value (12)
- wait (12)
-
wait
_ for _ cond (6) - wakeup (12)
検索結果
先頭5件
-
Thread
:: Queue # shift(non _ block = false) -> object (17125.0) -
キューからひとつ値を取り出します。キューが空の時、呼出元のスレッドは停止します。
..._block true を与えると、キューが空の時に例外 ThreadError が発生します。
//emlist[例][ruby]{
require 'thread'
q = Queue.new
th1 = Thread.start do
while resource = q.pop
puts resource
end
end
[:resource1, :resource2, :resource3, nil].each { |r|
q.push(r)
}
th1.jo......in
//}
//emlist[例: nonblock = true][ruby]{
require 'thread'
q = Queue.new
th1 = Thread.start do
while resource = q.pop
puts resource
end
end
[:resource1, :resource2, :resource3, nil].each { |r|
q.push(r)
}
begin
th1.join
q.pop(true)
rescue => e
p e
end
# => resource1
# resour......ce2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}... -
Thread
:: Queue # empty? -> bool (17107.0) -
キューが空の時、真を返します。
...キューが空の時、真を返します。
//emlist[例][ruby]{
require 'thread'
q = Queue.new
q.empty? # => true
q.push(:resource)
q.empty? # => false
//}... -
Thread
:: Queue # size -> Integer (17107.0) -
キューの長さを返します。
...キューの長さを返します。
//emlist[例][ruby]{
require 'thread'
q = Queue.new
[:resource1, :resource2, :resource3, nil].each { |r| q.push(r) }
q.length # => 4
//}... -
Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil (15349.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...トレースを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフ......locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrace_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace......::Location... -
Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil (15349.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...トレースを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフ......locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrace_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace......::Location... -
Thread
# backtrace -> [String] | nil (15213.0) -
スレッドの現在のバックトレースを返します。
...ist[例][ruby]{
class C1
def m1
sleep 5
end
def m2
m1
end
end
th = Thread.new {C1.new.m2; Thread.stop}
th.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] "(irb):10:in `block in irb_binding'"
# ]
th.kill
th.......backtrace # => nil
//}... -
Thread
# status -> String | false | nil (15167.0) -
生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず れかで返します。正常終了したスレッドに対して false、例外によ り終了したスレッドに対して nil を返します。
...orting" のいず
れかで返します。正常終了したスレッドに対して false、例外によ
り終了したスレッドに対して nil を返します。
Thread#alive? が真を返すなら、このメソッドも真です。
例:
a = Thread.new { raise("die now") }
b = Thread.n...... Thread.stop }
c = Thread.new { Thread.exit }
d = Thread.new { sleep }
d.kill #=> #<Thread:0x401b3678 aborting>
a.status #=> nil
b.status #=> "sleep"
c.status #=> false
d.status #=> "aborting"
Thread.current.......status #=> "run"
@see Thread#alive?, Thread#stop?... -
Thread
# report _ on _ exception -> bool (15155.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...$stderr に報告します。
デフォルトはスレッド作成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thr......stop; 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:......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) (15155.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...$stderr に報告します。
デフォルトはスレッド作成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thr......stop; 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:......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
# abort _ on _ exception -> bool (15153.0) -
真の場合、そのスレッドが例外によって終了した時に、インタプリタ 全体を中断させます。false の場合、あるスレッドで起こった例 外は、Thread#join などで検出されない限りそのスレッ ドだけをなにも警告を出さずに終了させます。
...スレッドで起こった例
外は、Thread#join などで検出されない限りそのスレッ
ドだけをなにも警告を出さずに終了させます。
デフォルトは偽です。c:Thread#exceptionを参照してください。
@param newstate 自身を実行中に例外発生し......た場合、インタプリタ全体を終了させるかどうかを true か false で指定します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.abort_on_exception # => false
thread.abort_on_exception = true
thread.abort_on_exception # => true
//}... -
Thread
# abort _ on _ exception=(newstate) (15153.0) -
真の場合、そのスレッドが例外によって終了した時に、インタプリタ 全体を中断させます。false の場合、あるスレッドで起こった例 外は、Thread#join などで検出されない限りそのスレッ ドだけをなにも警告を出さずに終了させます。
...スレッドで起こった例
外は、Thread#join などで検出されない限りそのスレッ
ドだけをなにも警告を出さずに終了させます。
デフォルトは偽です。c:Thread#exceptionを参照してください。
@param newstate 自身を実行中に例外発生し......た場合、インタプリタ全体を終了させるかどうかを true か false で指定します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.abort_on_exception # => false
thread.abort_on_exception = true
thread.abort_on_exception # => true
//}... -
Thread
# set _ trace _ func(pr) -> Proc | nil (15137.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, #<Binding:......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, #<Bindi......, :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, #<Binding:0x00007fc8de967798>, Thread]
# => ["c-return...