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); } }
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); } }
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; }
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); }
public void Attach(SingleFreeQueue3 <T> .Indexer next) { this.Attach(next.Array, next.Offset); }
public void SetIndex(SingleFreeQueue3 <T> .Indexer next) { this.SetIndex(next.Array, next.Offset); }