Class ConcurrentLinkedBlockingQueue2<T>

All Implemented Interfaces:
Serializable, Iterable<T>, Collection<T>, BlockingQueue<T>, Queue<T>

public class ConcurrentLinkedBlockingQueue2<T> extends ConcurrentLinkedQueue<T> implements BlockingQueue<T>
Attempt at writing a fast transfer queue, which is bounded. The take() method blocks until there is an element, but the offer() method drops the element and returns if the queue is full (doesn't block).

The design assumes a number of producers but only one consumer. The consumer only blocks when the queue is empty (on the not-empty condition), the producers block when the queue is full (on the not-full condition). The producers increment a count atomically and if the count is greater than the capacity, they block on the not-full condition. The consumer decrements the condition and signals the not-full condition when the count is capacity -1 (from capacity to capacity-1). The producers signal not-empty when the count is 1 (from 0 to 1)

Since:
3.5
See Also: