Class ConcurrentSequencedCircularArrayQueue<E>

    • Field Detail

      • sequenceBuffer

        protected final long[] sequenceBuffer
    • Constructor Detail

      • ConcurrentSequencedCircularArrayQueue

        public ConcurrentSequencedCircularArrayQueue(int capacity)
    • Method Detail

      • calcSequenceOffset

        protected final long calcSequenceOffset(long index)
      • soSequence

        protected final void soSequence(long[] buffer,
                                        long offset,
                                        long e)
      • lvSequence

        protected final long lvSequence(long[] buffer,
                                        long offset)
      • offer

        public boolean offer(M message)
        Called from a producer thread subject to the restrictions appropriate to the implementation and according to the Queue.offer(Object) interface (but failure to offer doesn't necessitate queue is full).
        Parameters:
        message -
        Returns:
        true if element was inserted into the queue, false if cannot enqueue
      • poll

        public M poll()
        Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue.poll() interface (barring the hard requirement on null returns).
        Returns:
        a message from the queue if one is available, null otherwise(not necessarily empty)
      • peek

        public M peek()
        Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue.peek() interface (barring the hard requirement on null returns).
        Returns:
        a message from the queue if one is available, null otherwise(not necessarily empty)
      • size

        public int size()
        This method's accuracy is subject to concurrent modifications happening as the size is estimated and as such is a best effort rather than absolute value. For some implementations this method may be O(n) rather than O(1).
        Returns:
        number of messages in the queue, between 0 and queue capacity or Integer.MAX_VALUE if not bounded
      • isEmpty

        public boolean isEmpty()
        This method's accuracy is subject to concurrent modifications happening as the observation is carried out.
        Returns:
        true if empty, false otherwise