[concurrency-interest] More control on 'full' with blockingqueue.

Bill Scherer scherer at cs.rochester.edu
Mon Aug 8 09:22:16 EDT 2005

On Sun, 7 Aug 2005, Peter Veentjer - Anchor Men wrote:

> I've not had the same problem, but if I'm understanding you correctly, it
> seems that a nice solution might be something along the lines of the
> following:
> Modify the various offer() and take() (and related) calls to accept a
> weight parameter (which would also need to be added into the Node class
> (see the insert() method). In your case, you'd supply this as a function
> of the document length. Then, instead of using getAndIncrement() and
> getAndDecrement() calls inside offer() and take(), use getAndAdd() (which
> can take a negative operand) to add the weight of the current document.
> ------------------
> This could be a solution and this would give an indication for the 
> remaining capacity.
> The advantage of totally externalizing the 'isfull' functionality is
> - I can share the instance between multiple queues and this make 
>   communication between them possible.
> - It is less restrictive. It doesn`t impose a numeric weight to each 
>   item. It seperates the what from the how better I think.
> If you need help getting this blocking queue variant working, let me know.
> -------------------
> Thanks for the offer, but I already have implemented a version based on 
> the LinkedBlockingQueue. Maybe you want to have a look at it?

I would be happy to take a look at it.

> And do you know if there are extensions available for the concurrency 
> library? For the Collection Framework there are numerous extensions 
> available, but I haven`t found any for the concurrency library.

I'm not aware of any, but I haven't gone looking for them either (so don't 
read too much into this).

 			-- Bill

More information about the Concurrency-interest mailing list