<commit_before>package disruptor

func (this *SingleProducerSequencer) Next(items int64) int64 {
	previous, gate := this.previous, this.gate
	next := previous + items
	wrap := next - this.ringSize

	if wrap > gate || gate > previous {
		barrier := this.barrier
		min := barrier.Load()
		for wrap > min || min < 0 {
			min = barrier.Load()
		}

		this.gate = min
	}

	this.previous = next
	return next
}

func NewSingleProducerSequencer(cursor *Sequence, ringSize int32, barrier Barrier) *SingleProducerSequencer {
	if !isPowerOfTwo(ringSize) {
		panic("The ring size must be a power of two, e.g. 2, 4, 8, 16, 32, 64, etc.")
	}

	return &SingleProducerSequencer{
		previous: InitialSequenceValue,
		gate:     InitialSequenceValue,
		cursor:   cursor,
		ringSize: int64(ringSize),
		barrier:  barrier,
	}
}
func isPowerOfTwo(value int32) bool {
	return value > 0 && (value&(value-1)) == 0
}

type SingleProducerSequencer struct {
	previous int64
	gate     int64
	cursor   *Sequence
	ringSize int64
	barrier  Barrier
}
<commit_msg>Pointing directly to "this" again--it appears to be slightly faster.<commit_after>package disruptor

func (this *SingleProducerSequencer) Next(items int64) int64 {
	next := this.previous + items
	wrap := next - this.ringSize

	if wrap > this.gate {
		min := this.barrier.Load()
		for wrap > min || min < 0 {
			min = this.barrier.Load()
		}

		this.gate = min
	}

	this.previous = next
	return next
}

func NewSingleProducerSequencer(cursor *Sequence, ringSize int32, barrier Barrier) *SingleProducerSequencer {
	if !isPowerOfTwo(ringSize) {
		panic("The ring size must be a power of two, e.g. 2, 4, 8, 16, 32, 64, etc.")
	}

	return &SingleProducerSequencer{
		previous: InitialSequenceValue,
		gate:     InitialSequenceValue,
		cursor:   cursor,
		ringSize: int64(ringSize),
		barrier:  barrier,
	}
}
func isPowerOfTwo(value int32) bool {
	return value > 0 && (value&(value-1)) == 0
}

type SingleProducerSequencer struct {
	previous int64
	gate     int64
	cursor   *Sequence
	ringSize int64
	barrier  Barrier
}

{'fraction_non_alphanumeric': 0.10724779627815867, 'fraction_numerical': 0.02840352595494613, 'mean_word_length': 3.852731591448931, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4375568', 'n_tokens_mistral': 764, 'n_tokens_neox': 692, 'n_words': 203}