///<summary> /// Increment sequence by a delta and get the result. /// The caller should be held up until the claimed sequence batch is available by tracking the dependentSequences. ///</summary> ///<param name="delta">delta to increment by.</param> /// <param name="dependentSequences">dependentSequences to be checked for range.</param> ///<returns>the result after incrementing.</returns> public long IncrementAndGet(int delta, Sequence[] dependentSequences) { long nextSequence = _claimSequence.AddAndGet(delta); WaitForFreeSlotAt(nextSequence, dependentSequences, _minGatingSequenceThreadLocal.Value); return(nextSequence); }
internal long NextInternal(int n) { var nextSequence = _cursor.AddAndGet(n); var current = nextSequence - n; var wrapPoint = nextSequence - _bufferSize; var cachedGatingSequence = _gatingSequenceCache.Value; if (wrapPoint > cachedGatingSequence || cachedGatingSequence > current) { var spinWait = default(AggressiveSpinWait); long gatingSequence; while (wrapPoint > (gatingSequence = DisruptorUtil.GetMinimumSequence(Volatile.Read(ref _gatingSequences), current))) { spinWait.SpinOnce(); } _gatingSequenceCache.SetValue(gatingSequence); } return(nextSequence); }