Class QueueConsumersImpl<T extends PriorityAware>

  • Type Parameters:
    T - The type this class may hold, this is generic as can be anything that extends PriorityAware, but intent is this is the QueueImpl:ConsumerHolder.
    All Implemented Interfaces:
    Iterable<T>, Iterator<T>, QueueConsumers<T>, RepeatableIterator<T>, ResettableIterator<T>

    public class QueueConsumersImpl<T extends PriorityAware>
    extends Object
    implements QueueConsumers<T>
    This class's purpose is to hold the consumers. CopyOnWriteArraySet is used as the underlying collection to the PriorityCollection, as it is concurrent safe, but also lock less for a read path, which is our HOT path. Also it was the underlying collection previously used in QueueImpl, before we abstracted it out to support priority consumers. There can only be one resettable iterable view, A new iterable view is created on modification, this is to keep the read HOT path performent, BUT the iterable view changes only after reset so changes in the underlying collection are only seen after a reset, All other iterators created by iterators() method are not reset-able and are created on delegating iterator().