public static void AddSequences(ref ISequence[] sequences, ICursored cursor, params ISequence[] sequencesToAdd) { long cursorSequence; ISequence[] updatedSequences; ISequence[] currentSequences; do { currentSequences = Volatile.Read(ref sequences); updatedSequences = new ISequence[currentSequences.Length + sequencesToAdd.Length]; Array.Copy(currentSequences, updatedSequences, currentSequences.Length); cursorSequence = cursor.Cursor; var index = currentSequences.Length; foreach (var sequence in sequencesToAdd) { sequence.SetValue(cursorSequence); updatedSequences[index++] = sequence; } } while (Interlocked.CompareExchange(ref sequences, updatedSequences, currentSequences) != currentSequences); cursorSequence = cursor.Cursor; foreach (var sequence in sequencesToAdd) { sequence.SetValue(cursorSequence); } }
/// <summary> /// Adds a sequence to the sequence group after threads have started to publish to /// the Disruptor.It will set the sequences to cursor value of the ringBuffer /// just after adding them. This should prevent any nasty rewind/wrapping effects. /// </summary> /// <param name="cursored">The data structure that the owner of this sequence group will be pulling it's events from</param> /// <param name="sequence">The sequence to add</param> public void AddWhileRunning(ICursored cursored, Sequence sequence) { SequenceGroups.AddSequences(ref _sequences, cursored, sequence); }
public void AddWhileRunning(ICursored cursored, ISequence sequence) { SequenceGroupManager.AddSequences(ref _sequences, cursored, sequence); }
/// <summary> /// Adds a sequence to the sequence group after threads have started to Publish to /// the Disruptor. It will set the sequences to cursor value of the ringBuffer /// just after adding them. This should prevent any nasty rewind/wrapping effects. /// </summary> /// <param name="cursored">The data structure that the owner of this sequence group will be pulling it's events from.</param> /// <param name="sequence">The sequence to add.</param> public void AddWhileRunning(ICursored cursored, Sequence sequence) { SequenceGroupManaging.AddSequences(this, sequencesRef, cursored, sequence); }
public SequencerFollowingSequence(ICursored sequencer) { _sequencer = sequencer; }
/// <summary> /// Construct a <see cref="IEventProcessor"/> that simply tracks a <see cref="Disruptor.Sequence"/>. /// </summary> /// <param name="sequencer">sequencer to track.</param> public NoOpEventProcessor(ICursored sequencer) { _sequence = new SequencerFollowingSequence(sequencer); }