示例#1
0
        public bool Acknowledge(Int24 datagramSequenceNumber)
        {
            var sequence = datagramSequenceNumber.IntValue();

            OutgoingAckQueue.Enqueue(sequence);

            var lastDatagram = Interlocked.Read(ref _lastDatagramSequenceNumber);

            if (sequence > lastDatagram)
            {
                var last    = Interlocked.CompareExchange(ref _lastDatagramSequenceNumber, sequence, lastDatagram);
                var skipped = sequence - last - 1;

                if (skipped > 0)
                {
                    for (long i = last; i < sequence; i++)
                    {
                        if (_nacked.TryAdd((int)i))
                        {
                            OutgoingNackQueue.Enqueue((int)i);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
示例#2
0
        public void Acknowledge(Int24 datagramSequenceNumber)
        {
            var integerValue = datagramSequenceNumber.IntValue();
            var last         = Interlocked.Exchange(ref _lastDatagramSequenceNumber, integerValue);
            var skipped      = last - integerValue - 1;

            if (skipped > 0)
            {
                for (long i = last + 1; i < integerValue - 1; i++)
                {
                    OutgoingNackQueue.Enqueue((int)i);
                }
            }

            OutgoingAckQueue.Enqueue(datagramSequenceNumber);
        }