I've been using the DefaultQueue from Excalibur 4.1 in a small pipeline-based project here. Although the javadocs state that its thread safe, I think there's a bug somewhere. Check out these numbers:
Default queue: Statistics: Source: [read: 21196] Connector: [read: 4868, write: 4868] Destination: [write: 3871] Statistics: Source: [read: 21196] Connector: [read: 4868, write: 4867] Destination: [write: 3870] Statistics: Source: [read: 21196] Connector: [read: 4868, write: 4868] Destination: [write: 2846] Statistics: Source: [read: 21196] Connector: [read: 5062, write: 5062] Destination: [write: 3040] Statistics: Source: [read: 21196] Connector: [read: 9159, write: 9159] Destination: [write: 5088] Statistics: Source: [read: 21196] Connector: [read: 13061, write: 13061] Destination: [write: 8990] LinkedListQueue (attached): Statistics: Source: [read: 21196] Connector: [read: 21196, write: 21195] Destination: [write: 21195] The off-by-one between the read/write in the connector is due to an element that doesn't pass it. That element doesn't make it to the connector each time! My setup is that I have 3 threads going, with a queue between each (2 queues). There is a sizeable number of elements being dropped in each stage. The LinkedListQueue is definitly much slower, ~6min versus ~1m for the DefaultQueue. I'm curious as to other's experiences with the DefaultQueue in a threaded environment. -pete -- peter royal -> [EMAIL PROTECTED]
package com.pace2020.edi.util; import java.util.Stack; import java.util.LinkedList; import java.util.Collections; import java.util.List; import java.util.NoSuchElementException; import org.apache.avalon.excalibur.event.Queue; import org.apache.avalon.excalibur.event.QueueElement; import org.apache.avalon.excalibur.event.SourceException; import org.apache.avalon.excalibur.event.PreparedEnqueue; import org.apache.avalon.excalibur.event.AbstractQueue; /** * @author Peter Royal * @version VSS $Revision: $ $Date: $ */ public class LinkedListQueue extends AbstractQueue { private LinkedList list = new LinkedList(); public void enqueue(QueueElement element) throws SourceException { synchronized (this) { this.list.add(element); } } public QueueElement dequeue() { synchronized (this) { try { return (QueueElement) this.list.removeFirst(); } catch (NoSuchElementException e) { return null; } } } public void enqueue(QueueElement[] elements) throws SourceException { throw new UnsupportedOperationException(); } public QueueElement[] dequeueAll() { throw new UnsupportedOperationException(); } public boolean tryEnqueue(QueueElement element) { throw new UnsupportedOperationException(); } public QueueElement[] dequeue(int num) { throw new UnsupportedOperationException(); } public PreparedEnqueue prepareEnqueue(QueueElement[] elements) throws SourceException { throw new UnsupportedOperationException(); } public int size() { synchronized(this) { return this.list.size(); } } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>