るりまサーチ (Ruby 2.7.0)

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

別のキーワード

  1. drb thread
  2. thread exit
  3. thread join
  4. thread kill
  5. etc sc_thread_cputime

ライブラリ

キーワード

検索結果

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

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

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

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

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

Thread::Queue#num_waiting -> Integer (27340.0)

キューを待っているスレッドの数を返します。

キューを待っているスレッドの数を返します。

//emlist[例][ruby]{
require 'thread'

q = SizedQueue.new(1)
q.push(1)
t = Thread.new { q.push(2) }
sleep 0.05 until t.stop?
q.num_waiting # => 1

q.pop
t.join
//}

Monitor#wait_for_cond(cond, timeout) -> true (18361.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...

Thread::ConditionVariable#broadcast -> self (9154.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 (9154.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)
...

絞り込み条件を変える

Thread::Queue#close -> self (9130.0)

キューを close します。close 済みのキューを再度 open することはできません。

キューを close します。close 済みのキューを再度 open することはできません。

close 後は以下のように動作します。

* Thread::Queue#closed? は true を返します
* Thread::Queue#close は無視されます
* Thread::Queue#enq/push/<< は ClosedQueueError を発生します
* Thread::Queue#empty? が false を返す場合は Thread::Queue#deq/pop/shift は通常通りオブジェクトを返します

また、ClosedQueueError...