Class AbstractConcurrentArrayQueue<E>

All Implemented Interfaces:
Iterable<E>, Collection<E>, Queue<E>, Pipe<E>, QueuedPipe<E>
Direct Known Subclasses:
ManyToManyConcurrentArrayQueue, ManyToOneConcurrentArrayQueue, OneToOneConcurrentArrayQueue

public abstract class AbstractConcurrentArrayQueue<E> extends AbstractConcurrentArrayQueuePadding3 implements QueuedPipe<E>
Left over immutable queue fields.
  • Field Details

    • TAIL_OFFSET

      protected static final long TAIL_OFFSET
      Offset of the tail field.
    • SHARED_HEAD_CACHE_OFFSET

      protected static final long SHARED_HEAD_CACHE_OFFSET
      Offset of the sharedHeadCache field.
    • HEAD_OFFSET

      protected static final long HEAD_OFFSET
      Offset of the head field.
    • BUFFER_ARRAY_BASE

      protected static final int BUFFER_ARRAY_BASE
      Array base.
    • SHIFT_FOR_SCALE

      protected static final int SHIFT_FOR_SCALE
      Shift for scale.
    • capacity

      protected final int capacity
      Queue capacity.
    • buffer

      protected final E[] buffer
      Backing array.
  • Constructor Details

    • AbstractConcurrentArrayQueue

      public AbstractConcurrentArrayQueue(int requestedCapacity)
      Constructs a queue with the requested capacity.
      Parameters:
      requestedCapacity - of the queue.
  • Method Details

    • addedCount

      public long addedCount()
      The number of items added to this container since creation.
      Specified by:
      addedCount in interface Pipe<E>
      Returns:
      the number of items added.
    • removedCount

      public long removedCount()
      The number of items removed from this container since creation.
      Specified by:
      removedCount in interface Pipe<E>
      Returns:
      the number of items removed.
    • capacity

      public int capacity()
      The maximum capacity of this container to hold items.
      Specified by:
      capacity in interface Pipe<E>
      Returns:
      the capacity of the container.
    • remainingCapacity

      public int remainingCapacity()
      Get the remaining capacity for elements in the container given the current size.
      Specified by:
      remainingCapacity in interface Pipe<E>
      Returns:
      remaining capacity of the container.
    • peek

      public E peek()
      Specified by:
      peek in interface Queue<E>
    • add

      public boolean add(E e)
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface Queue<E>
    • remove

      public E remove()
      Specified by:
      remove in interface Queue<E>
    • element

      public E element()
      Specified by:
      element in interface Queue<E>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<E>
    • iterator

      public Iterator<E> iterator()
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<E>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<E>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<E>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<E>
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Specified by:
      addAll in interface Collection<E>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<E>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<E>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<E>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<E>
    • size

      public int size()
      The number of items currently in the container.
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface Pipe<E>
      Returns:
      number of items currently in the container.
    • sequenceToBufferOffset

      public static long sequenceToBufferOffset(long sequence, long mask)
      Compute buffer offset based on the given sequence and the mask.
      Parameters:
      sequence - to compute the offset from.
      mask - to apply.
      Returns:
      buffer offset.