On Mon, May 27, 2002 at 09:43:48PM +0900, Lars Christensen wrote:
> On Mon, May 27, 2002 at 09:33:45PM +0900, Michael Neumann wrote:
> > On Mon, May 27, 2002 at 09:12:35PM +0900, Lars Christensen wrote:
> > > 
> > > Is this a bug in Ruby or my brain? :-)
> > > 
> > > $ sizedqueue.rb 
> > > quire 'thread.rb'
> > > q = SizedQueue.new(0)
> > > Thread.start { q.pop }
> > > q.push 1 
> > 
> > Maybe it has something to do that you define an empty queue? 
> > 
> > This works:
> > 
> > q = SizedQuere.new(n)  # n > 0 
> 
> But I want an empty queue. I expected pushing the first element on a queue with
> max 0 elements to block the thread, just as a pushing the 5th element on a full
> queue with max 4 elements.

The problem lies in thread.rb, method SizedQuere#push. It loops as long as
@que.length >= @max. For @max=0 this is an infinite loop, I guess.  

-- 
Michael Neumann  ***  eMail uu9r / rz.uni-karlsruhe.de