protected long claimUpTo ( int number ) { assert number > 0 ; long nextPosition = this . nextPosition ; long maxPosition = nextPosition + number ; long wrapPoint = maxPosition - bufferSize ; long cachedSlowestConsumerPosition = this . slowestConsumerPosition ; if ( wrapPoint > cachedSlowestConsumerPosition || cachedSlowestConsumerPosition > nextPosition ) { long minPosition ; while ( wrapPoint > ( minPosition = positionOfSlowestPointer ( nextPosition ) ) ) { // This takes on the order of tens of nanoseconds, so it's a useful activity to pause a bit. LockSupport . parkNanos ( 1L ) ; waitStrategy . signalAllWhenBlocking ( ) ; } this . slowestConsumerPosition = minPosition ; } this . nextPosition = maxPosition ; return maxPosition ; }
Claim up to the supplied number of positions .