Ejemplo n.º 1
0
 public void Initialize(Tick senderTick, Tick ackTick, SequenceId ackEventId, IEnumerable <Event> events)
 {
     SenderTick = senderTick;
     AckTick    = ackTick;
     AckEventId = ackEventId;
     PendingEvents.AddRange(events);
     EventsWritten = 0;
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public bool Contains(SequenceId value)
        {
            int difference = Latest - value;

            if (difference == 0)
            {
                return(true);
            }

            return(historyArray.Contains(difference - 1));
        }
Ejemplo n.º 4
0
        public bool IsNewId(SequenceId id)
        {
            if (ValueTooOld(id))
            {
                return(false);
            }

            if (Contains(id))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
 public bool ValueTooOld(SequenceId value)
 {
     return((Latest - value) > HISTORY_LENGTH);
 }
Ejemplo n.º 7
0
 public static bool AreInRange(SequenceId lowest, SequenceId highest)
 {
     return((highest - lowest) <= HISTORY_LENGTH);
 }
Ejemplo n.º 8
0
 private SequenceWindow(SequenceId latest, BitArray64 history)
 {
     Debug.Assert(latest.IsValid);
     Latest       = latest;
     historyArray = history;
 }
Ejemplo n.º 9
0
 public SequenceWindow(SequenceId latest)
 {
     Debug.Assert(latest.IsValid);
     Latest       = latest;
     historyArray = new BitArray64();
 }
Ejemplo n.º 10
0
 // SequenceId
 public static void WriteSequenceId(this BitBuffer buffer, SequenceId sequenceId)
 {
     buffer.Write(SequenceId.BITS_USED, sequenceId.RawValue);
 }