@Override
	long next(int n)
	{
		long current;
		long next;

		do
		{
			current = cursor.getAsLong();
			next = current + n;

			long wrapPoint = next - bufferSize;
			long cachedGatingSequence = gatingSequenceCache.getAsLong();

			if (wrapPoint > cachedGatingSequence || cachedGatingSequence > current)
			{
				long gatingSequence = RingBuffer.getMinimumSequence(gatingSequences, current);

				if (wrapPoint > gatingSequence)
				{
					if(spinObserver != null) {
						spinObserver.run();
					}
					LockSupport.parkNanos(1); // TODO, should we spin based on the wait strategy?
					continue;
				}

				gatingSequenceCache.set(gatingSequence);
			}
			else if (cursor.compareAndSet(current, next))
			{
				break;
			}
		}
		while (true);

		return next;
	}
@Override
	long next(int n)
	{
		long current;
		long next;

		do
		{
			current = cursor.getAsLong();
			next = current + n;

			long wrapPoint = next - bufferSize;
			long cachedGatingSequence = gatingSequenceCache.getAsLong();

			if (wrapPoint > cachedGatingSequence || cachedGatingSequence > current)
			{
				long gatingSequence = RingBuffer.getMinimumSequence(gatingSequences, current);

				if (wrapPoint > gatingSequence)
				{
					if(spinObserver != null) {
						spinObserver.run();
					}
					LockSupport.parkNanos(1); 
					continue;
				}

				gatingSequenceCache.set(gatingSequence);
			}
			else if (cursor.compareAndSet(current, next))
			{
				break;
			}
		}
		while (true);

		return next;
	}
@ Override long next ( int n ) { long current ; long next ; do { current = cursor . getAsLong ( ) ; next = current + n ; long wrapPoint = next - bufferSize ; long cachedGatingSequence = gatingSequenceCache . getAsLong ( ) ; if ( wrapPoint > cachedGatingSequence || cachedGatingSequence > current ) { long gatingSequence = RingBuffer . getMinimumSequence ( gatingSequences , current ) ; if ( wrapPoint > gatingSequence ) { if ( spinObserver != null ) { spinObserver . run ( ) ; } LockSupport . parkNanos ( 1 ) ; // TODO, should we spin based on the wait strategy? continue ; } gatingSequenceCache . set ( gatingSequence ) ; } else if ( cursor . compareAndSet ( current , next ) ) { break ; } } while ( true ) ; return next ; }
See {@code RingBufferProducer.next(int)}.
See {