Exemple #1
0
 internal void Reset()
 {
     lock (this.mutex)
     {
         this.head = null;
         this.tail = null;
     }
 }
Exemple #2
0
        internal SendPacket Retrieve(ushort sequence)
        {
            lock (this.mutex)
            {
                for (SendBufferElement e = this.head; e != null; e = e.next)
                {
                    if (e.data.packet.Sequence == sequence)
                    {
                        this.Remove(e);
                        return(e.data);
                    }
                }

                return(null);
            }
        }
Exemple #3
0
        private void Remove(SendBufferElement e)
        {
            if (e.prev == null)
            {
                this.head = e.next;
            }
            else
            {
                e.prev.next = e.next;
            }

            if (e.next == null)
            {
                this.tail = e.prev;
            }
            else
            {
                e.next.prev = e.prev;
            }
        }
Exemple #4
0
        internal void Add(Packet packet, bool noRTT)
        {
            lock (this.mutex)
            {
                SendBufferElement e = new SendBufferElement();
                e.data          = new SendPacket();
                e.data.packet   = packet;
                e.data.sendTime = Util.CurrentTime();
                e.data.noRTT    = noRTT;

                if (this.head == null)
                {
                    this.head = this.tail = e;
                }
                else
                {
                    e.prev         = this.tail;
                    this.tail.next = e;
                    this.tail      = e;
                }
            }
        }
Exemple #5
0
        internal void Iterate(Func <int, SendPacket, Operation> iterator)
        {
            lock (this.mutex)
            {
                int i = 0;

                for (SendBufferElement e = this.head; e != null; e = e.next)
                {
                    switch (iterator(i++, e.data))
                    {
                    case Operation.DELETE:
                        this.Remove(e);
                        break;

                    case Operation.CANCEL:
                        return;

                    case Operation.CONTINUE:
                        break;
                    }
                }
            }
        }