種類
- インスタンスメソッド (42)
- クラス (29)
- 特異メソッド (18)
- 文書 (15)
- 関数 (11)
クラス
- ThreadsWait (60)
キーワード
- ConditionVariable (11)
- ErrNoFinishedThread (6)
- ErrNoWaitingThread (6)
-
NEWS for Ruby 3
. 0 . 0 (4) - ThreadsWait (6)
-
all
_ waits (18) - empty? (6)
- finished? (6)
- join (6)
-
join
_ nowait (6) - new (6)
-
next
_ wait (6) -
rb
_ thread _ wait _ other _ threads (11) -
ruby 1
. 8 . 4 feature (11)
検索結果
先頭5件
-
ThreadsWait
# threads -> Array (24125.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 s... -
ThreadsWait
# join _ nowait(*threads) -> () (12259.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
. all _ waits(*threads) -> () (12226.0) -
指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。
...クを評価します。
@param threads 終了するまでまつスレッドを一つもしくは複数指定します。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
ThreadsWait.all_waits(*threads) {|th| printf("end %s\n", th.insp... -
ThreadsWait
. all _ waits(*threads) {|thread| . . . } -> () (12226.0) -
指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。
...クを評価します。
@param threads 終了するまでまつスレッドを一つもしくは複数指定します。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
ThreadsWait.all_waits(*threads) {|th| printf("end %s\n", th.insp... -
static void rb
_ thread _ wait _ other _ threads(void) (12200.0) -
-
ThreadsWait
# next _ wait(nonblock = nil) -> Thread (12125.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
# all _ waits -> () (12118.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)
}
# 出力例
#=> #<Thre... -
ThreadsWait
:: ErrNoWaitingThread (12006.0) -
終了を待つスレッドが存在しない時、発生します。
...終了を待つスレッドが存在しない時、発生します。
@see ThreadsWait#next_wait... -
ThreadsWait (12000.0)
-
複数スレッドの終了を待つ機能を提供します。
複数スレッドの終了を待つ機能を提供します。 -
ThreadsWait
. new(*threads) -> ThreadsWait (6325.0) -
指定されたスレッドの終了をまつための、スレッド同期オブジェクトをつくります。
...ります。
@param threads 終了を待つスレッドを一つもしくは複数指定します。
使用例
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new(*threads)
thall.all_waits{|th|
printf("end... -
ThreadsWait
# join(*threads) -> () (6159.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
# empty? -> bool (6030.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
# finished? -> bool (6018.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
:: ErrNoFinishedThread (6006.0) -
nonblock がtrue でかつ、キューが空の時、発生します。
...nonblock がtrue でかつ、キューが空の時、発生します。
@see ThreadsWait#next_wait... -
NEWS for Ruby 3
. 0 . 0 (36.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...argument will use `"(eval)"` for `__FILE__` and `1` for `__LINE__` in the evaluated code. 4352 17419
* ConditionVariable
* ConditionVariable#wait may now invoke the `block`/`unblock` scheduler hooks in a non-blocking context. 16786
* Dir
* Dir.glob and Dir.[] now sort the results by def......values. 15822
* IO
* IO#nonblock? now defaults to `true`. 16786
* IO#wait_readable, IO#wait_writable, IO#read, IO#write and other related methods (e.g. IO#puts, IO#gets) may invoke the scheduler hook `#io_wait(io, events, timeout)` in a non-blocking execution context. 16786
* Kernel......JIT-ed code when not necessary.
* GC-ing JIT-ed code is executed in a background thread.
* Reduce the number of locks between Ruby and JIT threads.
== Static analysis
=== RBS
* RBS is a new language for type definition of Ruby programs. It allows writing types of classes and modules wit... -
Thread
:: ConditionVariable (36.0) -
スレッドの同期機構の一つである状態変数を実現するクラスです。
...クラスです。
以下も ConditionVariable を理解するのに参考になります。
https://ruby-doc.com/docs/ProgrammingRuby/html/tut_threads.html#UF
=== Condition Variable とは
あるスレッド A が排他領域で動いていたとします。スレッド A は現在空いてい......状況を解決するのが Condition Variable です。
スレッド a で条件(リソースが空いているかなど)が満たされるまで wait メソッドで
スレッドを止めます。他のスレッド b において条件が満たされたなら signal
メソッドでスレッド a......onditionVariable.new
a = Thread.start {
mutex.synchronize {
...
while (条件が満たされない)
cv.wait(mutex)
end
...
}
}
b = Thread.start {
mutex.synchronize {
# 上の条件を満たすため...