るりまサーチ

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

別のキーワード

  1. cgi close
  2. _builtin close
  3. cgi/session close
  4. zlib close
  5. logger close

ライブラリ

検索結果

Thread::Queue#close -> self (18158.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
Thread.new{
while e = q.deq # wait for nil to break loop
# ...
end
}
q.close...

Thread::Queue#closed? -> bool (6123.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
//}...