Esempio n. 1
0
        public void Enqueue(IEnumerable <T> collection)
        {
            WriteFreeQueue <T> .QueueElement queueElement  = null;
            WriteFreeQueue <T> .QueueElement queueElement2 = null;
            foreach (T value in collection)
            {
                WriteFreeQueue <T> .QueueElement queueElement3 = new WriteFreeQueue <T> .QueueElement();

                queueElement3.Value = value;
                if (queueElement2 == null)
                {
                    queueElement = queueElement3;
                }
                else
                {
                    queueElement2.Next = queueElement3;
                }
                queueElement2 = queueElement3;
            }
            if (queueElement == null)
            {
                return;
            }
            while (Interlocked.CompareExchange <WriteFreeQueue <T> .QueueElement>(ref this.tail.Next, queueElement, null) != null)
            {
                Devcat.Core.WinNative.Thread.SwitchToThread();
            }
            this.tail = queueElement2;
        }
Esempio n. 2
0
        public void Enqueue(T value)
        {
            WriteFreeQueue <T> .QueueElement queueElement = new WriteFreeQueue <T> .QueueElement();

            queueElement.Value = value;
            while (Interlocked.CompareExchange <WriteFreeQueue <T> .QueueElement>(ref this.tail.Next, queueElement, null) != null)
            {
                Devcat.Core.WinNative.Thread.SwitchToThread();
            }
            this.tail = queueElement;
        }
Esempio n. 3
0
 public void Clear()
 {
     WriteFreeQueue <T> .QueueElement queueElement = this.tail;
     while (this.head != queueElement)
     {
         WriteFreeQueue <T> .QueueElement next = this.head.Next;
         this.head.Next  = null;
         this.head       = next;
         this.head.Value = default(T);
     }
 }