public TcpClientPacketProtocol(int bufferSize, int bufferPoolSize,ILoger loger)
 {
     this.loger = loger;
     if (BufferPool == null)
         BufferPool = new FixedBufferPool(bufferSize,bufferPoolSize);
     ReceiveBuffers = new Queue<IFixedBuffer>();
     SendBuffer = new FixedBuffer(bufferPoolSize);
 }
Пример #2
0
        public IFixedBuffer Pop()
        {
            IFixedBuffer buffer;

            if (!pool.TryPop(out buffer))
            {
                if (Interlocked.Increment(ref count) <= size)
                {
                    buffer = new FixedBuffer(bufferSize);
                }
            }
            return(buffer);
        }
        private ConcurrentQueue<SendData> sendDataQueue = new ConcurrentQueue<SendData>(); //指令发送队列

        #endregion Fields

        #region Constructors

        public TcpClientPacketProtocol(int bufferSize, int fixedBufferPoolSize)
        {
            if (BufferPool == null)
            {
                lock(closeLock)
                {
                    if(BufferPool==null)
                        BufferPool = new FixedBufferPool(fixedBufferPoolSize, bufferSize);
                }
            }
            ReceiveBuffers = new Queue<IFixedBuffer>();
            SendBuffer = new FixedBuffer(bufferSize);
            ReceiveDataBuffer = new DynamicBuffer(bufferSize);
        }