Class LockFreeBlockingQueue<E>

  • Type Parameters:
    E - The queue item data type
    All Implemented Interfaces:
    Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>

    public class LockFreeBlockingQueue<E>
    extends AbstractQueue<E>
    implements BlockingQueue<E>
    A blocking queue implementation which wraps the efficient ConcurrentLinkedQueue, and adds adaptive yields/sleeps in order to achieve a blocking behavior without using locks. The queue turns out to be more efficient than standard blocking queues (ArrayBlockingQueue and LinkedBlockingQueue), specially in cases of small queue capacity, or when producers and consumers aren't balanced in their rates. This implementation is optimized for overall throughput, but it's not intended for cases where latency of individual put(E) or take() operations is important. Therefore, this implementation is specially suitable for multithreaded pipelines.
    Author:
    Eyal Schneider