v7.3.2018.0614   重构高性能资源池,减少GC压力,增加线程池,让异步任务得到平等竞争CPU的机会
大石头 authored at 2018-06-14 17:56:44
649.00 B
X
using System;
using System.IO;
using NewLife.Queue.Storage;

namespace NewLife.Queue.Broker
{
    public class BufferLogRecord : ILogRecord
    {
        public byte[] RecordBuffer { get; set; }

        public void WriteTo(long logPosition, BinaryWriter writer)
        {
            writer.Write(RecordBuffer);
        }

        public void ReadFrom(byte[] recordBuffer)
        {
            RecordBuffer = new byte[4 + recordBuffer.Length];
            Buffer.BlockCopy(BitConverter.GetBytes(recordBuffer.Length), 0, RecordBuffer, 0, 4);
            Buffer.BlockCopy(recordBuffer, 0, RecordBuffer, 4, recordBuffer.Length);
        }
    }
}