Issue #4589 has been updated by Charles Nutter.


At first I thought this would be a good idea. But then I realized that #each is, in every case I can think of, a non-mutating operation. Since I assume you meant for Queue#each to pop all elements off the queue, this would be the first example I know of a mutating #each.

Also, what happens when the queue is empty? Does it wait for another element, or does it end the iteration?

The behavior of #each over a queue seems fuzzy to me, and without a clear specification of what you want I don't see a path forward.
----------------------------------------
Feature #4589: add Queue#each() method and include Enumerable
http://redmine.ruby-lang.org/issues/4589

Author: Suraj Kurapati
Status: Open
Priority: Normal
Assignee: 
Category: lib
Target version: 


Please add a thread-safe each() method to the Queue and SizedQueue classes
which are provided by the "thread" standard library

Also mix-in the Enumerable module into those classes so we can use map/inject/etc.

Thanks for your consideration.


-- 
http://redmine.ruby-lang.org