Akka.Interfaced.SlimSocket.Server.HeadTailWriteStream.Write C# (CSharp) Метод

Write() публичный Метод

public Write ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
Результат void
        public override void Write(byte[] buffer, int offset, int count)
        {
            int posEnd = _pos + count;
            EnsureCapacity(posEnd);

            int headSize = _head.Count;
            if (posEnd <= headSize)
            {
                // 데이터가 모두 Head 에만 기록될 경우

                var headOffset = _head.Offset + _pos;
                if (count <= 8)
                {
                    for (int i = 0; i < count; i++)
                        _head.Array[headOffset + i] = buffer[offset + i];
                }
                else
                {
                    Array.Copy(buffer, offset, _head.Array, headOffset, count);
                }
            }
            else if (_pos >= headSize)
            {
                // 데이터가 모두 Tail 에만 기록될 경우

                var tailOffset = _pos - headSize + _tail.Value.Offset;
                if (count <= 8)
                {
                    for (int i = 0; i < count; i++)
                        _tail.Value.Array[tailOffset + i] = buffer[offset + i];
                }
                else
                {
                    Array.Copy(buffer, offset, _tail.Value.Array, tailOffset, count);
                }
            }
            else
            {
                // 데이터가 Head 와 Tail 에 나눠 기록될 경우

                int headPartCount = headSize - _pos;
                int tailPartCount = posEnd - headSize;
                Array.Copy(buffer, 0, _head.Array, _head.Offset + _pos, headPartCount);
                Array.Copy(buffer, headPartCount, _tail.Value.Array, _tail.Value.Offset, tailPartCount);
            }

            _pos = posEnd;
            if (_length < posEnd)
                _length = posEnd;
        }