るりまサーチ (Ruby 2.7.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.077秒)
トップページ > 種類:インスタンスメソッド[x] > バージョン:2.7.0[x] > クエリ:Thread::ConditionVariable[x]

別のキーワード

  1. drb thread
  2. thread pending_interrupt?
  3. thread join
  4. thread exit
  5. thread kill

ライブラリ

キーワード

検索結果

Thread::ConditionVariable#wait(mutex, timeout = nil) -> self (63136.0)

mutex のロックを解放し、カレントスレッドを停止します。 Thread::ConditionVariable#signalまたは、 Thread::ConditionVariable#broadcastで送られたシグナルを 受け取ると、mutexのロックを取得し、実行状態となります。

mutex のロックを解放し、カレントスレッドを停止します。
Thread::ConditionVariable#signalまたは、
Thread::ConditionVariable#broadcastで送られたシグナルを
受け取ると、mutexのロックを取得し、実行状態となります。

@param mutex Mutex オブジェクトを指定します。

@param timeout スリープする秒数を指定します。この場合はシグナルを受け取
らなかった場合でも指定した秒数が経過するとスリープを終了
します。省略するとスリープし続け...

Thread::ConditionVariable#broadcast -> self (63052.0)

状態変数を待っているスレッドをすべて再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。

状態変数を待っているスレッドをすべて再開します。再開された
スレッドは Thread::ConditionVariable#wait
で指定した mutex のロックを試みます。

@return 常に self を返します。

//emlist[例][ruby]{
mutex = Mutex.new
cv = ConditionVariable.new
flg = true

3.times {
Thread.start {
mutex.synchronize {
puts "a1"
while (flg)
cv.wait(mutex)
...

Thread::ConditionVariable#signal -> self (63052.0)

状態変数を待っているスレッドを1つ再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。

状態変数を待っているスレッドを1つ再開します。再開された
スレッドは Thread::ConditionVariable#wait
で指定した mutex のロックを試みます。

@return 常に self を返します。

//emlist[例][ruby]{
mutex = Mutex.new
cv = ConditionVariable.new
flg = true

3.times {
Thread.start {
mutex.synchronize {
puts "a1"
while (flg)
cv.wait(mutex)
...

Monitor#wait_for_cond(cond, timeout) -> true (40.0)

MonitorMixin::ConditionVariable 用の内部メソッドです。

MonitorMixin::ConditionVariable 用の内部メソッドです。

@param cond Thread::ConditionVariable を指定します。
@param timeout タイムアウトまでの秒数。指定しなかった場合はタイムアウトしません。

@return Ruby 1.9 の頃からのバグで常に true を返します。(16608)

//emlist[例][ruby]{
require 'monitor'
m = Monitor.new
cv = Thread::ConditionVariable.new
m.enter
m.wait_for_cond...