public void Initialize(Tick senderTick, Tick ackTick, SequenceId ackEventId, IEnumerable <Event> events) { SenderTick = senderTick; AckTick = ackTick; AckEventId = ackEventId; PendingEvents.AddRange(events); EventsWritten = 0; }
// #region Operators private static int GetDifference(SequenceId a, SequenceId b) { Debug.Assert(a.IsValid); Debug.Assert(b.IsValid); var difference = (int)((a.RawValue << BIT_SHIFT) - (b.RawValue << BIT_SHIFT)); return(difference); }
public bool Contains(SequenceId value) { int difference = Latest - value; if (difference == 0) { return(true); } return(historyArray.Contains(difference - 1)); }
public bool IsNewId(SequenceId id) { if (ValueTooOld(id)) { return(false); } if (Contains(id)) { return(false); } return(true); }
public SequenceWindow Store(SequenceId value) { var latest = Latest; var historyArray = this.historyArray; int difference = Latest - value; if (difference > 0) { historyArray = this.historyArray.Store(difference - 1); } else { int offset = -difference; historyArray = (this.historyArray << offset).Store(offset - 1); latest = value; } return(new SequenceWindow(latest, historyArray)); }
public bool ValueTooOld(SequenceId value) { return((Latest - value) > HISTORY_LENGTH); }
public static bool AreInRange(SequenceId lowest, SequenceId highest) { return((highest - lowest) <= HISTORY_LENGTH); }
private SequenceWindow(SequenceId latest, BitArray64 history) { Debug.Assert(latest.IsValid); Latest = latest; historyArray = history; }
public SequenceWindow(SequenceId latest) { Debug.Assert(latest.IsValid); Latest = latest; historyArray = new BitArray64(); }
// SequenceId public static void WriteSequenceId(this BitBuffer buffer, SequenceId sequenceId) { buffer.Write(SequenceId.BITS_USED, sequenceId.RawValue); }