Skip to content

Commit

Permalink
Fixes #28: Size of SpscGrowableArrayQueue can exceeds max capacity
Browse files Browse the repository at this point in the history
Adjust producer limit in order to allow one more element to be added
in place of the unneeded JUMP when the max capacity producer buffer
has been allocated
  • Loading branch information
franz1981 committed Sep 7, 2018
1 parent 7ed3462 commit 63044f1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -114,7 +114,7 @@ final boolean offerColdPath(
long currConsumerIndex = lvConsumerIndex();
// use lookAheadStep to store the consumer distance from final buffer
this.lookAheadStep = -(index - currConsumerIndex);
producerBufferLimit = currConsumerIndex + maxCapacity - 1;
producerBufferLimit = currConsumerIndex + maxCapacity;
}
else
{
Expand Down
Expand Up @@ -106,7 +106,7 @@ final boolean offerColdPath(final AtomicReferenceArray<E> buffer, final long mas
long currConsumerIndex = lvConsumerIndex();
// use lookAheadStep to store the consumer distance from final buffer
this.lookAheadStep = -(index - currConsumerIndex);
producerBufferLimit = currConsumerIndex + maxCapacity - 1;
producerBufferLimit = currConsumerIndex + maxCapacity;
} else {
producerBufferLimit = index + producerMask - 1;
adjustLookAheadStep(newCapacity);
Expand Down

0 comments on commit 63044f1

Please sign in to comment.