public void IncomingData(byte[] buffer, int offset, int count)
        {
            lock (_sync)
            {
                if (count > 0)
                {
                    if (_tail == null)
                    {
                        _tail = _memory.Lease();
                    }

                    var iterator = new MemoryPoolIterator(_tail, _tail.End);
                    iterator.CopyFrom(buffer, offset, count);

                    if (_head == null)
                    {
                        _head = _tail;
                    }

                    _tail = iterator.Block;
                }
                else
                {
                    RemoteIntakeFin = true;
                }

                Complete();
            }
        }
        public void IncomingData(byte[] buffer, int offset, int count)
        {
            lock (_sync)
            {
                // Must call Add() before bytes are available to consumer, to ensure that Length is >= 0
                _bufferSizeControl?.Add(count);

                if (count > 0)
                {
                    if (_tail == null)
                    {
                        _tail = _memory.Lease();
                    }

                    var iterator = new MemoryPoolIterator(_tail, _tail.End);
                    iterator.CopyFrom(buffer, offset, count);

                    if (_head == null)
                    {
                        _head = _tail;
                    }

                    _tail = iterator.Block;
                }
                else
                {
                    RemoteIntakeFin = true;
                }

                Complete();
            }
        }
        public static int WriteBeginChunkBytes(ref MemoryPoolIterator start, int dataCount)
        {
            var chunkSegment = BeginChunkBytes(dataCount);

            start.CopyFrom(chunkSegment);
            return(chunkSegment.Count);
        }
Exemple #4
0
 public void CopyTo(ref MemoryPoolIterator output)
 {
     CopyToFast(ref output);
     if (MaybeUnknown != null)
     {
         foreach (var kv in MaybeUnknown)
         {
             foreach (var value in kv.Value)
             {
                 if (value != null)
                 {
                     output.CopyFrom(_CrLf, 0, 2);
                     output.CopyFromAscii(kv.Key);
                     output.CopyFrom(_colonSpace, 0, 2);
                     output.CopyFromAscii(value);
                 }
             }
         }
     }
 }
 public static void WriteEndChunkBytes(ref MemoryPoolIterator start)
 {
     start.CopyFrom(_endChunkBytes);
 }