るりまサーチ

最速Rubyリファレンスマニュアル検索!
1985件ヒット [101-200件を表示] (0.030秒)
トップページ > クエリ:threads[x]

別のキーワード

  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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 ... > >>

Etc::CS_POSIX_V7_THREADS_CFLAGS -> Integer (3102.0)

Etc.#confstr の引数に指定します。

Etc.#confstr の引数に指定します。

詳細は confstr(3) を参照してください。

Etc::CS_POSIX_V7_THREADS_LDFLAGS -> Integer (3102.0)

Etc.#confstr の引数に指定します。

Etc.#confstr の引数に指定します。

詳細は confstr(3) を参照してください。

ThreadsWait#empty? -> bool (3030.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 -> () (3018.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 (3018.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 (3018.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...

ThreadsWait::ErrNoFinishedThread (3000.0)

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

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

@see ThreadsWait#next_wait...

ThreadsWait::ErrNoWaitingThread (3000.0)

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

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

@see ThreadsWait#next_wait...

Thread#value -> object (36.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 (30.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 (30.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}...

Enumerator (6.0)

each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。 また、外部イテレータとしても使えます。

...ます。
例えば以下のようなスレッドをまたいだ呼び出しはエラーになります。

//emlist[例][ruby]{
a = nil
Thread.new do
a = [1, 2, 3].each
a.next
end.join

p a.next
#=> t.rb:7:in `next': fiber called across threads (FiberError)
# from t.rb:7:in `<main>'
//}...

Fiber (6.0)

ノンプリエンプティブな軽量スレッド(以下ファイバーと呼ぶ)を提供します。 他の言語では coroutine あるいは semicoroutine と呼ばれることもあります。 Thread と違いユーザレベルスレッドとして実装されています。

...レッド間をまたがるファイバーの切り替えはできません。
例外 FiberError が発生します。

//emlist[例:][ruby]{
f = nil
Thread.new do
f = Fiber.new{}
end.join
f.resume
#=> t.rb:5:in `resume': fiber called across threads (FiberError)
# from t.rb:5:in `<main>'
//}...
<< < 1 2 3 4 ... > >>