示例#1
0
 public void Enqueue <U>(IEnumerable <U> values, Converter <U, T> converter)
 {
     ChunkSegment <SingleFreeQueue3 <T> .Element> .ChunkSegmentContext context = ChunkSegment <SingleFreeQueue3 <T> .Element> .Context;
     SingleFreeQueue3 <T> .Indexer next  = default(SingleFreeQueue3 <T> .Indexer);
     SingleFreeQueue3 <T> .Indexer index = default(SingleFreeQueue3 <T> .Indexer);
     next.Invalidate();
     foreach (U input in values)
     {
         ArraySegment <SingleFreeQueue3 <T> .Element> arraySegment = context.Get(1);
         arraySegment.Array[arraySegment.Offset].Initialize(converter(input));
         if (!next.Valid)
         {
             next.SetIndex(arraySegment.Array, arraySegment.Offset);
         }
         else
         {
             index.Attach(arraySegment.Array, arraySegment.Offset);
         }
         index.SetIndex(arraySegment.Array, arraySegment.Offset);
     }
     if (next.Valid)
     {
         this.tail.Attach(next);
         this.tail.SetIndex(index);
     }
 }
示例#2
0
 public void Clear()
 {
     while (this.head.Next.Valid)
     {
         SingleFreeQueue3 <T> .Indexer next = this.head.Next;
         this.head.Detach();
         this.head       = next;
         this.head.Value = default(T);
     }
 }
示例#3
0
        private void ExtendThreadQueue(int threadID)
        {
            int i;

            for (i = this.threadLocalQueue.Length * 2; i <= threadID; i *= 2)
            {
            }
            SingleFreeQueue3 <KeyValuePair <int, T> >[] destinationArray = new SingleFreeQueue3 <KeyValuePair <int, T> > [i];
            Array.Copy(this.threadLocalQueue, destinationArray, this.threadLocalQueue.Length);
            this.threadLocalQueue = destinationArray;
        }
示例#4
0
        public T Dequeue()
        {
            if (this.Empty)
            {
                throw new InvalidOperationException("Queue is Empty.");
            }
            SingleFreeQueue3 <T> .Indexer next = this.head.Next;
            this.head.Detach();
            this.head = next;
            T value = this.head.Value;

            this.head.Value = default(T);
            return(value);
        }
示例#5
0
 public void Attach(SingleFreeQueue3 <T> .Indexer next)
 {
     this.Attach(next.Array, next.Offset);
 }
示例#6
0
 public void SetIndex(SingleFreeQueue3 <T> .Indexer next)
 {
     this.SetIndex(next.Array, next.Offset);
 }