584件ヒット
[201-300件を表示]
(0.145秒)
別のキーワード
クラス
- Exception (11)
- Fiber (22)
- Mutex (2)
-
Net
:: IMAP (44) -
Net
:: IMAP :: ThreadMember (22) -
Rake
:: Application (11) - Thread (221)
-
Thread
:: Backtrace :: Location (33) -
Thread
:: Mutex (9) -
Thread
:: Queue (55) -
Thread
:: SizedQueue (51) - ThreadGroup (44)
- ThreadsWait (42)
キーワード
- [] (11)
-
abort
_ on _ exception (11) -
abort
_ on _ exception= (11) -
absolute
_ path (11) - add (11)
-
add
_ trace _ func (11) -
all
_ waits (6) -
backtrace
_ locations (11) - children (11)
-
client
_ thread (11) -
client
_ thread= (11) - deq (22)
- empty? (24)
- enclose (11)
- enclosed? (11)
- exit (11)
- finished? (6)
- group (11)
- inspect (22)
- join (6)
-
join
_ nowait (6) - keys (11)
- kill (11)
- list (11)
-
next
_ wait (6) - path (11)
-
pending
_ interrupt? (11) - pop (22)
- priority (11)
- priority= (11)
- push (22)
- raise (11)
-
report
_ on _ exception (8) -
report
_ on _ exception= (8) - resume (11)
- seqno (11)
-
set
_ trace _ func (11) - shift (22)
- sleep (11)
- stop? (11)
-
sync
_ upgrade _ waiting (6) - terminate (11)
- threads (6)
- timeout (11)
-
to
_ s (7) - transfer (11)
-
uid
_ thread (11) - value (11)
- wakeup (11)
検索結果
先頭5件
-
ThreadsWait
# threads -> Array (9143.0) -
同期されるスレッドの一覧を配列で返します。
...ドの一覧を配列で返します。
使用例
require 'thwait'
threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new(*threads)
p thall.threads
#=> [#<Thread:0x21750 sleep>, #<Thread:0x216c4 sleep>, #<Thread:0x21638 sleep>]... -
Thread
# [](name) -> object | nil (9139.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...@param name スレッド固有データのキーを文字列か Symbol で指定します。
//emlist[例][ruby]{
[
Thread.new { Thread.current["name"] = "A" },
Thread.new { Thread.current[:name] = "B" },
Thread.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts "#{th.inspe......ct}: #{th[:name]}"
end
# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a54130 dead>: C
//}
Thread#[] と Thread#[]= を用いたスレッド固有の変数は
Fiber を切り替えると異なる変数を返す事に注意してください......。
//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread.current[:name] = newvalue
yield
ensure
Thread.current[:name] = oldvalue
end
end
//}
この関数に与えるブロックがFiberを切り替える場合は動的スコープとしては
正... -
ThreadsWait
# empty? -> bool (9131.0) -
同期されるスレッドが存在するならば true をかえします。
...ッドが存在するならば true をかえします。
使用例
require 'thwait'
threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new
p thall.threads.empty? #=> true
thall.join(*threads)
p thall.threads.empty? #=> false... -
Thread
# raise(error _ type , message , traceback) -> () (9119.0) -
自身が表すスレッドで強制的に例外を発生させます。
...す。
@param error_type Kernel.#raise を参照してください。
@param message Kernel.#raise を参照してください。
@param traceback Kernel.#raise を参照してください。
Thread.new {
sleep 1
Thread.main.raise "foobar"
}
begin
sleep
rescue
p $!, $@... -
Thread
:: Backtrace :: Location # inspect -> String (9117.0) -
Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。
...
Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文
字列に変換したオブジェクトを返します。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).loc......ations.map do |call|
puts call.inspect
end
# => "path/to/foo.rb:5:in `initialize'"
# "path/to/foo.rb:9:in `new'"
# "path/to/foo.rb:9:in `<main>'"
//}... -
Thread
:: Backtrace :: Location # path -> String (9113.0) -
self が表すフレームのファイル名を返します。
...self が表すフレームのファイル名を返します。
例: Thread::Backtrace::Location の例1を用いた例
//emlist[][ruby]{
loc = c(0..1).first
loc.path # => "caller_locations.rb"
//}
@see Thread::Backtrace::Location#absolute_path... -
Thread
:: Backtrace :: Location # absolute _ path -> String (9107.0) -
self が表すフレームの絶対パスを返します。
...][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.absolute_path
end
# => /path/to/foo.rb
# /path/to/foo.rb
# /path/to/foo.rb
//}
@see Thread::Backtrace::Location#path... -
Thread
:: Mutex # sleep(timeout = nil) -> Integer (9107.0) -
与えられた秒数の間ロックを解除してスリープして、実行後にまたロックします。
...リープして、実行後にまたロックします。
@param timeout スリープする秒数を指定します。省略するとスリープし続けます。
@return スリープしていた秒数を返します。
@raise ThreadError 自身がカレントスレッドによってロックさ......グナルを受信した場合などに実行が再
開(spurious wakeup)される場合がある点に注意してください。
//emlist[例][ruby]{
m = Mutex.new
th = Thread.new do
m.lock
m.sleep(2)
end
th.status # => "run"
sleep 1
th.status # => "sleep"
sleep 1
th.status # => false
//}......にまたロックします。
@param timeout スリープする秒数を指定します。省略するとスリープし続けます。
@return タイムアウトした時は nil を、それ以外はスリープしていた秒数を返します。
@raise ThreadError 自身がカレントスレ... -
Net
:: IMAP # client _ thread=(th) (9102.0) -
このメソッドは obsolete です。使わないでください。
このメソッドは obsolete です。使わないでください。 -
Thread
:: Queue # empty? -> bool (9101.0) -
キューが空の時、真を返します。
...キューが空の時、真を返します。
//emlist[例][ruby]{
q = Queue.new
q.empty? # => true
q.push(:resource)
q.empty? # => false
//}... -
Thread
:: SizedQueue # empty? -> bool (9101.0) -
キューが空の時、真を返します。
キューが空の時、真を返します。 -
Thread
# value -> object (9053.0) -
スレッド self が終了するまで待ち(Thread#join と同じ)、 そのスレッドのブロックが返した値を返します。スレッド実行中に例外が 発生した場合には、その例外を再発生させます。
...ッド self が終了するまで待ち(Thread#join と同じ)、
そのスレッドのブロックが返した値を返します。スレッド実行中に例外が
発生した場合には、その例外を再発生させます。
スレッドが Thread#kill によって終了した場合は、......了を待ち結果を出力する例です。
threads = []
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.each {|t| p t.value}
最後の行で、待ち合わせ......を行っていることがわかりにくいと思うなら以下
のように書くこともできます。
threads.each {|t| p t.join.value}...