New Queue API

Jean Morissette <[email protected]> Wed, 19 Jan 2005 17:58:33 -0500
Newsgroups gmane.comp.java.seda.user
Message-ID <[email protected]>
Hi,
I see that bulk queue operation like dequeue_all, blocking_dequeue_all 
and blocking_dequeue_all(int timeout) produce a big overhead because 
these methods create each time an array of QueueElementIF.  So, to 
improve performance, I would like to provide a more performant queue API 
for bulk operations.

Thus, I suggest to add these new methods in Source/BlockingSource:

   int dequeueAll(Collection c);
   int dequeue(Collection c, int maxElements);
   int blockingDequeueAll(Collection c, int timeout);
   int blockingDequeue(Collection c, int timeout, int maxElements);

And for symmetry, we could have in Sink/BlockingSink:

   void enqueueMany(Collection c) throws SinkException;
   TransactionIF enqueuePrepare(Collection c) throws SinkException;
   void enqueuePrepare(Collection c, TransactionIF txn)
       throws  SinkException;

Of course, I will deprecate their corresponding array-based methods.

The only drawback that I see with these methods is that the client must 
not modify the given collection while calling these methods.  It's 
particularly true for the Sink side.  By exemple, the client should not 
modify the collection between enqueuePrepare and enqueueCommit, else we 
will enter in an unpredictable state.

I continue to doubt that it's a good idea to provide any bulk operations 
on the sink side.  IMHO, we should provide only the same methods than 
j.u.c.BlockingQueue.  Also, talking with Doug Lea, he don't think that 
bulk operations on the sink side would be more fast than simple 
looping...  So, for now, I suggest to only add bulk collection-based 
operations in the source side.

I will have to do benchmark to know if bulk operations in sink side 
offer better performance or not.



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl