Пример #1
0
        private void TryParsingReceivedData(ConcurrentQueue <ReceivedData> receiveQueue)
        {
            if (!EnterParsing())
            {
                return;
            }
            try
            {
                var dataList    = new List <ReceivedData>(receiveQueue.Count);
                var segmentList = new List <ArraySegment <byte> >();

                ReceivedData data;
                while (receiveQueue.TryDequeue(out data))
                {
                    dataList.Add(data);
                    segmentList.Add(new ArraySegment <byte>(data.Buf.Array, data.Buf.Offset, data.DataLen));
                }

                _framer.Package(segmentList);

                for (int i = 0, n = dataList.Count; i < n; ++i)
                {
                    _receiveDataBufferPool.Return(dataList[i].Buf.Array);
                }
            }
            finally
            {
                ExitParsing();
            }
        }