るりまサーチ

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

別のキーワード

  1. _builtin enq
  2. queue enq
  3. sizedqueue enq
  4. thread enq
  5. enq

ライブラリ

クラス

検索結果

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

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

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

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

* Thread::Queue#closed? は true を返します
* Thread::Queue#close は無視されます
* Thread::Queue#enq/push/<< は ClosedQueueError...
...オブジェクトを返します

また、ClosedQueueError は StopIteration を継承しているため、
close
する事でループから脱出する事もできます。

例:

q = Queue.new
Thread.new{
while e = q.deq # wait for nil to break loop
# ...
end
}
q.close...