種類
- インスタンスメソッド (157)
- 特異メソッド (22)
- クラス (11)
クラス
-
Encoding
:: Converter (44) - StopIteration (11)
- Thread (104)
-
Thread
:: Queue (9) - Time (11)
キーワード
- Thread (11)
- alive? (11)
- backtrace (11)
-
handle
_ interrupt (11) -
num
_ waiting (9) -
primitive
_ convert (44) -
report
_ on _ exception (8) -
report
_ on _ exception= (8) - result (11)
- run (11)
- status (11)
- stop? (11)
- strftime (11)
- wakeup (11)
検索結果
先頭5件
-
Thread
. stop -> nil (26115.0) -
他のスレッドから Thread#run メソッドで再起動されるまで、カレ ントスレッドの実行を停止します。
...ドから Thread#run メソッドで再起動されるまで、カレ
ントスレッドの実行を停止します。
//emlist[例][ruby]{
a = Thread.new { print "a"; Thread.stop; print "c" }
sleep 0.1 while a.status!='sleep'
print "b"
a.run
a.join
# => "abc"
//}
@see Thread#run, Thread#wakeup... -
Thread
# stop? -> bool (14143.0) -
スレッドが終了(dead)あるいは停止(stop)している時、true を返します。
...スレッドが終了(dead)あるいは停止(stop)している時、true を返します。
//emlist[例][ruby]{
a = Thread.new { Thread.stop }
b = Thread.current
a.stop? # => true
b.stop? # => false
//}
@see Thread#alive?, Thread#status... -
StopIteration
# result -> object (11008.0) -
この例外オブジェクトを発生させる原因となったメソッド等の返り値を返します。
...を返します。
object = Object.new
def object.each
yield :yield1
yield :yield2
:each_returned
end
enumerator = object.to_enum
p enumerator.next #=> :yield1
p enumerator.next #=> :yield2
begin
enumerator.next
rescue StopIteration => error
p error.result #... -
Thread
# report _ on _ exception=(newstate) (8126.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_excep......aceback (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
# status -> String | false | nil (8038.0) -
生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず れかで返します。正常終了したスレッドに対して false、例外によ り終了したスレッドに対して nil を返します。
...。
Thread#alive? が真を返すなら、このメソッドも真です。
例:
a = Thread.new { raise("die now") }
b = Thread.new { 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
# run -> self (8036.0) -
停止状態(stop)のスレッドを再開させます。 Thread#wakeup と異なりすぐにスレッドの切り替え を行います。
...止状態(stop)のスレッドを再開させます。
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
# wakeup -> self (8036.0) -
停止状態(stop)のスレッドを実行可能状態(run)にします。
...停止状態(stop)のスレッドを実行可能状態(run)にします。
@raise ThreadError 死んでいるスレッドに対して実行すると発生します。
//emlist[例][ruby]{
c = Thread.new { Thread.stop; puts "hey!" }
sleep 0.1 while c.status!='sleep'
c.wakeup
c.join
# => "hey!"
//}......@see Thread#run, Thread.stop... -
Thread
# report _ on _ exception -> bool (8026.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...成時の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_excep......aceback (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... -
Time
# strftime(format) -> String (8026.0) -
時刻を format 文字列に従って文字列に変換した結果を返します。
...空白埋めにする
* 0: 0埋めにする
* 数値: 表示桁数を指定する
EとOは無視されます。
//emlist[例][ruby]{
p t = Time.new(2001,2,3,4,5,6,"+09:00") # => 2001-02-03 04:05:06 +0900
p t.strftime("Printed on %m/%d/%Y") # => "Printed on 02/03/2001"
p t.strftime("Printe......") # => "at 04:05AM"
p t.strftime("at %I:%M%#p") # => "at 04:05am"
//}
//emlist[様々なISO 8601形式][ruby]{
t = Time.new(2001,2,3,4,5,6,"+09:00")
p t.strftime("%Y%m%d") # => 20010203 Calendar date (basic)
p t.strftime("%F") # =.......%L") # => 040506.000 Local time with decimal fraction, full stop as decimal sign (basic)
p t.strftime("%T.%L") # => 04:05:06.000 Local time with decimal fraction, full stop as decimal sign (extended)
p t.strftime("%H%M%S%z") # => 040506+0900... -
Thread (8020.0)
-
スレッドを表すクラスです。スレッドとはメモリ空間を共有して同時に実行される制御の流れです。 Thread を使うことで並行プログラミングが可能になります。
...の
スレッドがある場合、その待っているスレッドに対して、同じ例外が再度
発生します。
begin
t = Thread.new do
Thread.pass # メインスレッドが確実にjoinするように
raise "unhandled exception"
end
t.join
rescue
p $!......以下の実行状態を持ちます。これらの状態は
Object#inspect や
Thread#status によって見ることができます。
p Thread.new {sleep 1} # => #<Thread:0xa039de0 sleep>
: run (実行or実行可能状態)
生成されたばかりのスレッドや Thread#run や
Thread#wake......ドの
終了によりこの状態になります。
この状態のスレッドは「生きて」います。
: sleep (停止状態)
Thread.stop や Thread#join により停止されたスレッ
ドはこの状態になります。
この状態のスレッドは「生きて」います。...