From: SASADA Koichi Date: 2012-04-19T15:20:50+09:00 Subject: [ruby-core:44450] Re: [ruby-trunk - Feature #6293][Assigned] new queue / blocking queues Hi, (2012/04/17 0:24), Aaron Patterson wrote: >>> So calling pop() means we're doing a not not blocking call. :( >> >> How about to add try_pop? > > try_pop seems fine, but it still seems strange to combine blocking > and non-blocking queues (but maybe *I* am the one who is strange). > > In the case of BlockingQueue#pop in the patch I submitted, it > allows a timeout. I don't think it's a feature that should be > abandoned. I understand that ::Queue#pop should receive timeout extra parameter. However, I'm not sure we need to separate (Blocking|Unblocking)Queue yet. >> How >>> >> about to implement Queue#to_a method that generate array which >> contains queues containing objects? > > That seems fine! Then we can eliminate Enumerable mixed in. :-) Yes. And it is clear semantics. ::Queue#each can be implemented on at least two semantics: 1) block the end of queue. (like IO) 2) return when reach end of queue. (like Array) Against IO, Queue#each with semantics (1) can't stop. It is similar to the cycle object (generated by Enumerator#cycle). -- // SASADA Koichi at atdot dot net