るりまサーチ

最速Rubyリファレンスマニュアル検索!
18件ヒット [1-18件を表示] (0.128秒)
トップページ > クエリ:-[x] > クエリ:r[x] > クエリ:close[x] > クラス:Thread::Queue[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

検索結果

Thread::Queue#close -> self (21258.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 は StopIteration を継承しているため、
close
する事でループから脱出する事もできます。

例:

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

Thread::Queue#closed? -> bool (9235.0)

キューが close されている時に true を返します。

...キューが close されている時に true を返します。

//emlist[例][ruby]{
q = Queue.new

[:resource1, :resource2, :resource3, nil].each { |r| q.push(r) }

q.closed? # => false
q.close
q.closed? # => true
//}...