Re: A new queue has come

Jean Morissette <[email protected]> Sat, 04 Dec 2004 13:33:15 -0500
Newsgroups gmane.comp.java.seda.user
Message-ID <[email protected]>
Quartz wrote:
>>My DynamicArrayBlockingQueue should be very effecient in situation 
>>without a lot of contention.
> 
> I don't see how. Could you pass that by me again?

You can see my DynamicArrayBlockingQueue in the CVS.  This queue should 
be very fast compared with FiniteQueue.

Soon, I will write a LinkedBlockingQueue that should be more scalable, 
thus more efficient with lot of contention.  Also, I will forget my 
weird MultiArrayBlockingQueue for now (this queue is a hybrid because it 
use probably arrays and linked nodes).

> ...unless you're still thinking about saving arraycopies,
> because then I don't wanna know ;) I use a drum list.

What do you mean by "drum list"?


>>I have already thinking about that.  Why don't create methods 
>>QueueIF.dequeue_all(List list) and EventHandlerIF.handleEvents(List 
>>list).  We could specify in the EventHandlerIF specification that this 
>>list cannot be cached by user.  Like this, we could reuse our list 
>>(ArrayList) and don't create QueueElementIF array all the time.  Seem a 
>>good idea.
> 
> 
> If I would rather lend an array/offset/length to handlers than a list, 
> unless the list is reused, cleared and refilled efficiently (upon dequeue(n)).
> Same difference, both list and array can be reused.
> 
> The difference between lending and giving the list/array is a major semantic change.
> Stages were allowed to use the array as is, and even ship it as one single object to perform work,
> even pass this to other threads/sinks. That is a lot of handlers to refactor...
> 
> I chose not to reuse the array, because handlers would create an new array anyway it they needed
> their own. I guess a handler could have a 'boolean giveNewArray()' method to tell the TM how to
> pass events. Just as good a tip as the current SingleThreadedEventHandlerIF marker interface.


Yes, it's a big semantic change, but _only_ handlers that need a copy 
can do that easily:

public void handleEvent(List sharedList) {
   List myCopy = new ArrayList(sharedList);
   ...
}

Users that need their copy just have to add one line of code!
So, I think that creating a new 'giveNewArray()' method or a marker 
interface is overkill; we just need to change the specification.






-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/