예제 #1
0
        public SocketAsyncEventArgsPool(int poolSize, int maxSize, int bufferSize)
        {
            _maxPoolSize = maxSize;
            _argsPool = new BlockingCollection<SocketAsyncEventArgs>(new ConcurrentQueue<SocketAsyncEventArgs>());
            _bufferManager = new BufferManager(bufferSize);

            Init(poolSize);
        }
예제 #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _argsPool.CompleteAdding();

                while (_argsPool.Count > 0)
                {
                    SocketAsyncEventArgs arg = _argsPool.Take();

                    _bufferManager.ClearBuffer(arg);
                    arg.Dispose();
                }
            }

            _bufferManager = null;
        }