[concurrency-interest] LinkedBlockedQueue

Doug Lea dl@cs.oswego.edu
Mon, 29 Sep 2003 20:11:56 -0400

> > I gather that what you are looking for is a non-existent method
> >   <T> T[] drain(T[] array)
> > and/or  
> >   void drain(Collection<E> c, int maxElements)
> > that drains (i.e., removes) up to maxElements elements into 
> > an array or collection.  
> >
> > Could you give a compelling use case or two showing why you 
> > need something like this?  Can anyone else?
> Can't speak for others, but I use queues to introduce an isolated
> execution boundary in my application. The units of work enqueued on each
> queue are small and fast to compute so I would like to process a big
> batch (say 100-1000) of events each time. If I need to poll each single
> element I would pay a penalty both in form of acquiring/releasing a lot
> of locks and in form of a lot of switches between unrelated pieces of
> code, thereby destroying the program locality (caching/ branch
> predictors).

While I can see the benefit, I'm waiting to see if someone else on
this list says "yes I really need this". Otherwise, the amount of
effort to add this to all BlockingQueues is hard to justify for a
specialized usage.