るりまサーチ

最速Rubyリファレンスマニュアル検索!
75件ヒット [1-75件を表示] (0.101秒)

別のキーワード

  1. etc sc_threads
  2. etc sc_thread_threads_max
  3. etc sc_xopen_realtime_threads
  4. etc cs_posix_v7_threads_cflags
  5. etc cs_posix_v7_threads_ldflags

ライブラリ

クラス

キーワード

検索結果

ThreadsWait#threads -> Array (21126.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 slee...

ThreadsWait#join(*threads) -> () (3160.0)

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。

...threads で指定されたスレッドを指定します。

@param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。

require 'thwait'

threads
= []
5.times {|i|
threads
<< Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWai...
...t.new
p thall.threads #=> []
thall.join(*threads)
p thall.threads
#=> [#<Thread:0x216ec dead>, #<Thread:0x21660 dead>, #<Thread:0x215d4 dead>, #<Thread:0x214bc dead>]...

ThreadsWait#join_nowait(*threads) -> () (3160.0)

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。 しかし、実際には終了をまちません。

...して、threads で指定されたスレッドを指定します。
しかし、実際には終了をまちません。

@param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。

require 'thwait'

threads
= []
5.times {|i|
threads
<< Threa...
...d.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new
p thall.threads #=> []
thall.join_nowait(*threads)
p thall.threads #=> [#<Thread:0x21638 sleep>, #<Thread:0x215ac sleep>, #<Thread:0x21520 sleep>, #<Thread:0x21494 sleep>, #<Thread:0x21408 sleep>]
# 実際には終了を待...

ThreadsWait#empty? -> bool (3031.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...

ThreadsWait#all_waits -> () (3019.0)

指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。

...レッド終了時にブロックを評価します。

使用例
require 'thwait'

threads
= []
5.times {|i|
threads
<< Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new(*threads)
thall.all_waits{|th|
printf("end %s\n", th.inspect)
}

# 出力例
#=>...

絞り込み条件を変える

ThreadsWait#finished? -> bool (3019.0)

すでに終了したスレッドが存在すれば true を返します。

...に終了したスレッドが存在すれば true を返します。

使用例
require 'thwait'

threads
= []
3.times {|i|
threads
<< Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new(*threads)
p thall.finished? #=> false
sleep 3
p thall.finished? #=> true...

ThreadsWait#next_wait(nonblock = nil) -> Thread (3019.0)

指定したスレッドのどれかが終了するまで待ちます。

... ThreadsWait::ErrNoFinishedThread が発生します。

@raise ErrNoWaitingThread 終了をまつスレッドが存在しない時、発生します。

@raise ErrNoFinishedThread nonblock がtrue でかつ、キューが空の時、発生します。

#使用例
require 'thwait'

threads
= [...
...]
2.times {|i|
threads
<< Thread.new { sleep i }
}

thall = ThreadsWait.new
thall.join_nowait(*threads)
until thall.empty?
th = thall.next_wait
p th
end

@see Queue#pop...

Thread#value -> object (37.0)

スレッド self が終了するまで待ち(Thread#join と同じ)、 そのスレッドのブロックが返した値を返します。スレッド実行中に例外が 発生した場合には、その例外を再発生させます。

...の終了を待ち結果を出力する例です。

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}...

Thread#join -> self (31.0)

スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。

...

以下は、生成したすべてのスレッドの終了を待つ例です。

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| t.join}...

Thread#join(limit) -> self | nil (31.0)

スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。

...

以下は、生成したすべてのスレッドの終了を待つ例です。

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| t.join}...

絞り込み条件を変える