Class MpscGrowableArrayQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueuePad1<E>
com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueProducerFields<E>
com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueuePad2<E>
com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueConsumerFields<E>
com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueuePad3<E>
com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueColdProducerFields<E>
com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue<E>
com.github.benmanes.caffeine.cache.MpscChunkedArrayQueueColdProducerFields<E>
com.github.benmanes.caffeine.cache.MpscChunkedArrayQueue<E>
com.github.benmanes.caffeine.cache.MpscGrowableArrayQueue<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Queue<E>
An MPSC array queue which starts at initialCapacity and grows to maxCapacity in
linked chunks of the initial size. The queue grows only when the current buffer is full and
elements are not copied on resize, instead a link to the new buffer is stored in the old buffer
for the consumer to follow.
This is a shaded copy of MpscGrowableArrayQueue provided by JCTools from version 2.0.
-
Field Summary
Fields inherited from class com.github.benmanes.caffeine.cache.MpscChunkedArrayQueue
p0, p1, p10, p11, p12, p13, p14, p15, p16, p17, p2, p3, p4, p5, p6, p7
Fields inherited from class com.github.benmanes.caffeine.cache.MpscChunkedArrayQueueColdProducerFields
maxQueueCapacity
Fields inherited from class com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueColdProducerFields
producerBuffer, producerLimit, producerMask
Fields inherited from class com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueConsumerFields
consumerBuffer, consumerIndex, consumerMask
Fields inherited from class com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueuePad2
p01, p02, p03, p04, p05, p06, p07
Fields inherited from class com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueProducerFields
producerIndex
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected long
getCurrentBufferCapacity
(long mask) protected int
getNextBufferSize
(E[] buffer) Methods inherited from class com.github.benmanes.caffeine.cache.MpscChunkedArrayQueue
availableInQueue, capacity
Methods inherited from class com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue
allocate, currentConsumerIndex, currentProducerIndex, isEmpty, iterator, offer, peek, poll, relaxedOffer, relaxedPeek, relaxedPoll, size, toString
Methods inherited from class java.util.AbstractCollection
contains, containsAll, remove, removeAll, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
MpscGrowableArrayQueue
public MpscGrowableArrayQueue(int initialCapacity, int maxCapacity) - Parameters:
initialCapacity
- the queue initial capacity. If chunk size is fixed this will be the chunk size. Must be 2 or more.maxCapacity
- the maximum capacity will be rounded up to the closest power of 2 and will be the upper limit of number of elements in this queue. Must be 4 or more and round up to a larger power of 2 than initialCapacity.
-
-
Method Details
-
getNextBufferSize
- Overrides:
getNextBufferSize
in classMpscChunkedArrayQueue<E>
- Returns:
- next buffer size(inclusive of next array pointer)
-
getCurrentBufferCapacity
protected long getCurrentBufferCapacity(long mask) - Overrides:
getCurrentBufferCapacity
in classMpscChunkedArrayQueue<E>
- Returns:
- current buffer capacity for elements (excluding next pointer and jump entry) * 2
-