Example #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);
     }
 }
Example #2
0
        public void Enqueue(T value)
        {
            ArraySegment <SingleFreeQueue3 <T> .Element> arraySegment = ChunkSegment <SingleFreeQueue3 <T> .Element> .Get(1);

            arraySegment.Array[arraySegment.Offset].Initialize(value);
            this.tail.Attach(arraySegment.Array, arraySegment.Offset);
            this.tail.SetIndex(arraySegment.Array, arraySegment.Offset);
        }
Example #3
0
        public SingleFreeQueue3()
        {
            ChunkSegment <SingleFreeQueue3 <T> .Element> .AllocationSize = 256;
            ArraySegment <SingleFreeQueue3 <T> .Element> arraySegment = ChunkSegment <SingleFreeQueue3 <T> .Element> .Get(1);

            arraySegment.Array[arraySegment.Offset].Next.Invalidate();
            this.head = default(SingleFreeQueue3 <T> .Indexer);
            this.head.SetIndex(arraySegment.Array, arraySegment.Offset);
            this.tail = this.head;
        }
Example #4
0
        public Packet(int length, PacketType packetType)
        {
            this       = default(Packet);
            this.Bytes = ChunkSegment <byte> .Get(10 + length);

            Buffer.SetByte(this.Bytes.Array, this.Bytes.Offset, 175);
            byte[] bytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(length + 5));
            Buffer.BlockCopy(bytes, 0, this.Bytes.Array, this.Bytes.Offset + 1, bytes.Length);
            this.PacketNo   = ++Packet.packetNo;
            this.PacketType = packetType;
            this.offset     = this.Bytes.Offset + 10;
        }
Example #5
0
        internal Packet(int contentLength, PacketType packetType)
        {
            this = default(Packet);
            if (65534 < contentLength)
            {
                throw new ArgumentOutOfRangeException("contentLength", "65534을 초과합니다.");
            }
            short num = (short)(contentLength + 1);

            this.Bytes = ChunkSegment <byte> .Get((int)(num + 3));

            Buffer.SetByte(this.Bytes.Array, this.Bytes.Offset, 170);
            byte[] bytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(num));
            Buffer.BlockCopy(bytes, 0, this.Bytes.Array, this.Bytes.Offset + 1, bytes.Length);
            this.PacketType = packetType;
            this.offset     = this.Bytes.Offset + 4;
        }
Example #6
0
        private bool TokenizeHeader()
        {
            if (this.length <= this.position)
            {
                return(false);
            }
            int num = Math.Min(this.header.Length - this.headerOffset, this.length - this.position);

            Buffer.BlockCopy(this.buffer, this.position, this.header, this.headerOffset, num);
            this.headerOffset += num;
            this.position     += num;
            if (this.headerOffset < this.header.Length)
            {
                return(false);
            }
            short num2 = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(this.header, 1));

            this.headerOffset = 0;
            this.data         = ChunkSegment <byte> .Get(this.header.Length + (int)num2);

            Buffer.BlockCopy(this.header, 0, this.data.Array, this.data.Offset, this.header.Length);
            this.dataOffset = this.header.Length;
            return(true);
        }
Example #7
0
 internal Packet(int length, int categoryId)
 {
     this            = new Packet(ChunkSegment <byte> .Get(8 + Packet.GetBytesCount(categoryId) + Packet.GetBytesCount(length) + length));
     this.CategoryId = categoryId;
     this.Length     = length;
 }